pike.git / lib / modules / Concurrent.pmod

version» Context lines:

pike.git/lib/modules/Concurrent.pmod:439:    STATE_FULFILLED : "fulfilled" ])[state],    result);    }   }      class aggregate_state {    private Promise promise;    private int(0..) promises;    private int(0..) succeeded, failed;    final array(mixed) results; -  final int(0..) min_failed; -  final int(-1..) max_failed; +  final int(0..) min_failures; +  final int(-1..) max_failures;    final mixed accumulator;    final function(mixed, mixed, mixed ... : mixed) fold_fun;    final array(mixed) extra;       private void create(Promise p) {    if (p->_materialised || p->_materialised++)    error("Cannot materialise a Promise more than once.\n");    promise = p;    }   
pike.git/lib/modules/Concurrent.pmod:490:    results = 0; // Free memory    }       private void cb_failure(mixed value, int idx) {    Promise p; // Cache it, to cover a failure race    if (p = promise) {    object key = mux->lock();    do {    if (!p->state) {    ++failed; -  if (max_failed < failed && max_failed >= 0) { +  if (max_failures < failed && max_failures >= 0) {    key = 0;    p->try_failure(value);    break;    }    int success = succeeded + failed == promises;    key = 0;    if (results)    results[idx] = value;    else    fold_one(value);    if (success) { -  fold(failed >= min_failed ? p->success : p->failure); +  fold(failed >= min_failures ? p->success : p->failure);    break;    }    } else    key = 0;    return;    } while (0);    promise = 0; // Free backreference    }    }       private void cb_success(mixed value, int idx) {    Promise p; // Cache it, to cover a failure race    if (p = promise) {    object key = mux->lock();    do {    if (!p->state) {    ++succeeded; -  if (promises - min_failed < succeeded) { +  if (promises - min_failures < succeeded) {    key = 0;    p->try_failure(value);    break;    }    int success = succeeded + failed == promises;    key = 0;    if (results)    results[idx] = value;    else    fold_one(value);
pike.git/lib/modules/Concurrent.pmod:715:    object key = mux->lock();    if (state) return;    unlocked_failure(value);    }       inline private void fill_astate() {    if (!_astate)    _astate = aggregate_state(this);    }    -  //! Add futures which the current object depends on. +  //! Add futures to the list of futures which the current object depends upon.    //!    //! If called without arguments it will produce a new @[Future]    //! from a new @[Promise] which is implictly added to the dependency list.    //!    //! @param futures    //! The list of @expr{futures@} we want to add to the list we depend on.    //!    //! @returns    //! The new @[Promise].    //!    //! @note    //! Can be called multiple times to add more.    //!    //! @note    //! Once the promise has been materialised (when either @[on_success()],    //! @[on_failure()] or @[get()] has been called on this object), it is    //! not possible to call @[depend()] anymore.    //!    //! @seealso -  //! @[fold()], @[first_completed()], @[max_failed()], @[min_failed()], +  //! @[fold()], @[first_completed()], @[max_failures()], @[min_failures()],    //! @[any_results()], @[Concurrent.results()], @[Concurrent.all()]    this_program depend(array(Future) futures)    {    if (sizeof(futures)) {    fill_astate();    _astate->results += futures;    }    return this_program::this;    }    inline variant this_program depend(Future ... futures)
pike.git/lib/modules/Concurrent.pmod:776:    //! as arguments three and onwards when @[fun] is called.    //!    //! @returns    //! The new @[Promise].    //!    //! @note    //! If @[fun] throws an error it will fail the @[Future].    //!    //! @note    //! @[fun] may be called in any order, and will be called -  //! once for every @[Future] it depends on, unless one of the +  //! once for every @[Future] it depends upon, unless one of the    //! calls fails in which case no further calls will be    //! performed.    //!    //! @seealso    //! @[depend()], @[Concurrent.fold()]    this_program fold(mixed initial,    function(mixed, mixed, mixed ... : mixed) fun,    mixed ... extra)    {    if (_astate) {    _astate->accumulator = initial;    _astate->fold_fun = fun;    _astate->extra = extra;    _astate->materialise();    } else    success(initial);    return this_program::this;    }       //! It evaluates to the first future that completes of the list -  //! of futures it depends on. +  //! of futures it depends upon.    //!    //! @returns    //! The new @[Promise].    //!    //! @seealso    //! @[depend()], @[Concurrent.first_completed()]    this_program first_completed()    {    if (_astate) {    _astate->results->on_failure(try_failure);
pike.git/lib/modules/Concurrent.pmod:824:       //! @param max    //! Specifies the maximum number of failures to be accepted in    //! the list of futures this promise depends upon. Defaults    //! to @expr{0@}. @expr{-1@} means unlimited.    //!    //! @returns    //! The new @[Promise].    //!    //! @seealso -  //! @[depend()], @[min_failed()], @[any_results()] -  this_program max_failed(int(-1..) max) +  //! @[depend()], @[min_failures()], @[any_results()] +  this_program max_failures(int(-1..) max)    {    fill_astate(); -  _astate->max_failed = max; +  _astate->max_failures = max;    return this_program::this;    }       //! @param min    //! Specifies the minimum number of failures to be required in    //! the list of futures this promise depends upon. Defaults    //! to @expr{0@}.    //!    //! @returns    //! The new @[Promise].    //!    //! @seealso -  //! @[depend()], @[max_failed()] -  this_program min_failed(int(0..) min) +  //! @[depend()], @[max_failures()] +  this_program min_failures(int(0..) min)    {    fill_astate(); -  _astate->min_failed = min; +  _astate->min_failures = min;    return this_program::this;    }       //! Sets the number of failures to be accepted in the list of futures    //! this promise -  //! depends upon to unlimited. It is equivalent to @expr{max_failed(-1)@}. +  //! depends upon to unlimited. It is equivalent to @expr{max_failures(-1)@}.    //!    //! @returns    //! The new @[Promise].    //!    //! @seealso -  //! @[depend()], @[max_failed()] +  //! @[depend()], @[max_failures()]    this_program any_results()    { -  return max_failed(-1); +  return max_failures(-1);    }       protected void _destruct()    {    if (!state) {    unlocked_failure(({ "Promise broken.\n", backtrace() }));    }    }   }