pike.git / lib / modules / Concurrent.pmod

version» Context lines:

pike.git/lib/modules/Concurrent.pmod:78:    //!    //! @seealso    //! @[on_failure()]    this_program on_success(function(mixed, mixed ... : void) cb, mixed ... extra)    {    object key = mux->lock();       if (state == STATE_FULFILLED) {    call_out(cb, 0, result, @extra);    key = 0; -  return this; +  return this_program::this;    }       success_cbs += ({ ({ cb, extra }) });    key = 0;    -  return this; +  return this_program::this;    }       //! Register a callback that is to be called on failure.    //!    //! @param cb    //! Function to be called. The first argument will be the    //! failure result of the @[Future].    //!    //! @param extra    //! Any extra context needed for @[cb]. They will be provided
pike.git/lib/modules/Concurrent.pmod:109:    //!    //! @seealso    //! @[on_success()]    this_program on_failure(function(mixed, mixed ... : void) cb, mixed ... extra)    {    object key = mux->lock();       if (state == STATE_REJECTED) {    call_out(cb, 0, result, @extra);    key = 0; -  return this; +  return this_program::this;    }       failure_cbs += ({ ({ cb, extra }) });    key = 0;    -  return this; +  return this_program::this;    }       //! Apply @[fun] with @[val] followed by the contents of @[ctx],    //! and update @[p] with the result.    protected void apply(mixed val, Promise p,    function(mixed, mixed ... : mixed) fun,    array(mixed) ctx)    {    mixed err = catch {    p->success(fun(val, @ctx));
pike.git/lib/modules/Concurrent.pmod:197:       //! Return a @[Future] that will be fulfilled with the result    //! of applying @[fun] with the fulfilled result of this @[Future]    //! followed by @[extra].    //!    //! @note    //! This method is used if your @[fun] returns a regular value (i.e.    //! @b{not@} a @[Future]).    //!    //! @seealso -  //! @[flat_map()], @[transform()], @[recover()] +  //! @[map_with()], @[transform()], @[recover()]    this_program map(function(mixed, mixed ... : mixed) fun, mixed ... extra)    {    Promise p = Promise();    on_failure(p->failure);    on_success(apply, p, fun, extra);    return p->future();    }       //! Return a @[Future] that will be fulfilled with the fulfilled result    //! of applying @[fun] with the fulfilled result of this @[Future]    //! followed by @[extra].    //!    //! @note    //! This method is used if your @[fun] returns a @[Future] again.    //!    //! @seealso -  //! @[map()], @[transform_with()], @[recover_with()] -  this_program flat_map(function(mixed, mixed ... : this_program) fun, +  //! @[map()], @[transform_with()], @[recover_with()], @[flat_map] +  this_program map_with(function(mixed, mixed ... : this_program) fun,    mixed ... extra)    {    Promise p = Promise();    on_failure(p->failure);    on_success(apply_flat, p, fun, extra);    return p->future();    }    -  +  //! This is an alias for @[map_with()]. +  //! +  //! @seealso +  //! @[map_with()] +  inline this_program flat_map(function(mixed, mixed ... : this_program) fun, +  mixed ... extra) +  { +  return map_with(fun, @extra); +  } +     //! Return a @[Future] that will be fulfilled with either    //! the fulfilled result of this @[Future], or the result    //! of applying @[fun] with the failed result followed    //! by @[extra].    //!    //! @note    //! This method is used if your callbacks returns a regular value (i.e.    //! @b{not@} a @[Future]).    //!    //! @seealso
pike.git/lib/modules/Concurrent.pmod:253:       //! Return a @[Future] that will be fulfilled with either    //! the fulfilled result of this @[Future], or the fulfilled result    //! of applying @[fun] with the failed result followed    //! by @[extra].    //!    //! @note    //! This method is used if your callbacks returns a @[Future] again.    //!    //! @seealso -  //! @[recover()], @[flat_map()], @[transform_with()] +  //! @[recover()], @[map_with()], @[transform_with()]    this_program recover_with(function(mixed, mixed ... : this_program) fun,    mixed ... extra)    {    Promise p = Promise();    on_success(p->success);    on_failure(apply_flat, p, fun, extra);    return p->future();    }       //! Return a @[Future] that either will by fulfilled by the
pike.git/lib/modules/Concurrent.pmod:310:    //! the fulfilled result of applying @[success] with the fulfilled result    //! followed by @[extra], or the fulfilled result of applying @[failure]    //! with the failed result followed by @[extra].    //!    //! @[failure] defaults to @[success].    //!    //! @note    //! This method is used if your callbacks returns a @[Future] again.    //!    //! @seealso -  //! @[transform()], @[flat_map()], @[recover_with] +  //! @[transform()], @[map_with()], @[recover_with]    this_program transform_with(function(mixed, mixed ... : this_program) success,    function(mixed, mixed ... : this_program)|void failure,    mixed ... extra)    {    Promise p = Promise();    on_success(apply_flat, p, success, extra);    on_failure(apply_flat, p, failure || success, extra);    return p->future();    }   
pike.git/lib/modules/Concurrent.pmod:604:    astate[1] += allocate(sizeof(futures), UNDEFINED);       futures->on_failure(try_failure);       foreach(futures; int i; Future f) {    int x = base + i;    astate[0][x] = 1;    f->on_success(depend_success, x, astate);    }    } -  return this; +  return this_program::this;    }    inline variant this_program depend(Future ... futures)    {    return depend(futures);    }    variant this_program depend()    {    Promise p = Promise();    depend(p->future());    return p;
pike.git/lib/modules/Concurrent.pmod:652:    //! The new @[Promise].    //!    //! @seealso    //! @[Concurrent.fold()], @[apply_fold()]    this_program fold(array(Future) futures)    {    if (!astate)    astate = ({});       astate += futures; -  return this; +  return this_program::this;    }    inline variant this_program fold(Future ... futures)    {    return fold(futures);    }    variant this_program fold()    {    Promise p = Promise();    fold(p->future());    return p;
pike.git/lib/modules/Concurrent.pmod:697:    //! performed.    //!    //! @seealso    //! @[Concurrent.fold()], @[fold()]    this_program apply_fold(mixed initial,    function(mixed, mixed, mixed ... : mixed) fun,    mixed ... extra)    {    if (!astate || !sizeof(astate)) {    success(initial); -  return this; +  return this_program::this;    }       array(Future) futures = astate;    astate = 0;    multiset pending = (<>);    array astate = ({pending, initial});       futures->on_failure(try_failure);       foreach(futures; int i; Future f) {    pending[i] = 1;    f->on_success(fold_success, i, astate, fun, @extra);    } -  return this; +  return this_program::this;    }       protected void fold_success(mixed val, int i, array astate,    function(mixed, mixed, mixed ... : mixed) fun,    mixed ... extra)    {    multiset pending = astate[0];    if (state || !pending[i]) return;    object key = mux->lock();    if (state || !pending[i]) return;