pike.git / lib / modules / Concurrent.pmod

version» Context lines:

pike.git/lib/modules/Concurrent.pmod:163:    protected void apply_flat(mixed val, Promise p,    function(mixed, mixed ... : Future) fun,    array(mixed) ctx)    {    mixed err = catch {    Future f = fun(val, @ctx);    if (!objectp(f) || !f->on_failure || !f->on_success) {    error("Expected %O to return a Future. Got: %O.\n",    fun, f);    } -  f->on_failure(p->failure); -  f->on_success(p->success); +  f->on_failure(p->failure)->on_success(p->success);    return;    };    p->failure(err);    }       //! Apply @[fun] with @[val] followed by the contents of @[ctx],    //! and update @[p] with the eventual result.    protected void apply_smart(mixed val, Promise p,    function(mixed, mixed ... : mixed|Future) fun,    array(mixed) ctx)    {    mixed err = catch {    mixed|Future f = fun(val, @ctx);    if (!objectp(f)    || !functionp(f->on_failure) || !functionp(f->on_success)) {    p->success(f);    return;    } -  f->on_failure(p->failure); -  f->on_success(p->success); +  f->on_failure(p->failure)->on_success(p->success);    return;    };    p->failure(err);    }       //! Apply @[fun] with @[val] followed by the contents of @[ctx],    //! and update @[p] with @[val] if @[fun] didn't return false.    //! If @[fun] returned false fail @[p] with @[UNDEFINED].    protected void apply_filter(mixed val, Promise p,    function(mixed, mixed ... : int(0..1)) fun,
pike.git/lib/modules/Concurrent.pmod:347:    on_failure(apply_flat, p, fun, extra);    return p->future();    }       //! This specifies a callback that is only called on success, and    //! allows you to selectively alter the future into a failure.    //!    //! @param fun    //! Function to be called. The first argument will be the    //! @b{success@} result of @b{this@} @[Future]. -  //! If the return value is @expr{true}, the future succeeds with +  //! If the return value is @expr{true@}, the future succeeds with    //! the original success result. -  //! If the return value is @expr{false}, the future fails with +  //! If the return value is @expr{false@}, the future fails with    //! an @[UNDEFINED] result.    //!    //! @param extra    //! Any extra context needed for    //! @expr{fun@}. They will be provided    //! as arguments two and onwards when the callback is called.    //!    //! @returns    //! The new @[Future].    //!
pike.git/lib/modules/Concurrent.pmod:590:    if (promise->_astate)    {    promise->_astate = 0;    if (results)    {    promises = sizeof(results);    array(Future) futures = results;    if (fold_fun)    results = 0;    foreach(futures; int idx; Future f) -  { -  f->on_failure(cb_failure, idx); -  f->on_success(cb_success, idx); +  f->on_failure(cb_failure, idx)->on_success(cb_success, idx);    }    }    } -  } +        private void fold_one(mixed val)    {    mixed err = catch (accumulator = fold_fun(val, accumulator, @extra));    if (err && promise)    promise->failure(err);    }       private void fold(function(mixed:void) failsucc)    {
pike.git/lib/modules/Concurrent.pmod:941:    //! 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); -  _astate->results->on_success(try_success); +  _astate->results->on_failure(try_failure)->on_success(try_success);    _astate = 0;    } else    success(0);    return this_program::this;    }       //! @param max    //! Specifies the maximum number of failures to be accepted in    //! the list of futures this promise depends upon.    //!