pike.git / lib / modules / Concurrent.pmod

version» Context lines:

pike.git/lib/modules/Concurrent.pmod:341:   protected class Results   {    inherit Promise;       protected void create(array(Future) futures)    {    if (!sizeof(futures)) {    success(({}));    return;    } +  +  array(mixed) results = allocate(sizeof(futures), UNDEFINED); +  array(State) states = allocate(sizeof(futures), STATE_PENDING); +     futures->on_failure(failure); -  +     foreach(futures; int i; Future f) { -  f->on_success(got_success, i, -  allocate(sizeof(futures), UNDEFINED), -  allocate(sizeof(futures), STATE_PENDING)); +  f->on_success(got_success, i, results, states);    }    }       protected void got_success(mixed value, int i,    array(mixed) results, array(State) states)    {    if (state == STATE_REJECTED) return;    results[i] = value;    states[i] = STATE_FULFILLED;    if (!state) { -  if (has_value(states, STATE_PENDING)) return; +  if (has_value(states, STATE_PENDING)) { +  return;    } -  +  }    success(results);    }   }      //! Return a @[Future] that represents the array of all   //! the completed @[futures].   Future results(array(Future) futures)   {    Promise p = Results(futures);    return p->future();