pike.git / lib / modules / Concurrent.pmod

version» Context lines:

pike.git/lib/modules/Concurrent.pmod:196:    //! result of the @[Future].    //!    //! @param extra    //! Any extra context needed for @[cb]. They will be provided    //! as arguments two and onwards when @[cb] is called.    //!    //! @note    //! @[cb] will always be called from the main backend.    //!    //! @seealso -  //! @[on_failure()] +  //! @[on_failure()], @[query_success_callbacks()]    this_program on_success(function(mixed, mixed ... : void) cb, mixed ... extra)    {    switch (state) {    case STATE_FULFILLED:    call_callback(cb, result, @extra);    break;    case STATE_NO_FUTURE:    case STATE_PENDING:    // Rely on interpreter lock to add to success_cbs before state changes    // again    success_cbs += ({ ({ cb, @extra }) });    }    return this_program::this;    }    -  +  //! Query the set of active success callbacks. +  //! +  //! @returns +  //! Returns an array with callback functions. +  //! +  //! @seealso +  //! @[on_success()], @[query_failure_callbacks()] +  array(function) query_success_callbacks() +  { +  return column(success_cbs, 0); +  } +     //! 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    //! as arguments two and onwards when @[cb] is called.    //!    //! @note    //! @[cb] will always be called from the main backend.    //!    //! @seealso -  //! @[on_success()] +  //! @[on_success()], @[query_failure_callbacks()]    this_program on_failure(function(mixed, mixed ... : void) cb, mixed ... extra)    {    switch (state) {    case STATE_REJECTED:    state = STATE_REJECTION_REPORTED;    // FALL_THROUGH    case STATE_REJECTION_REPORTED:    call_callback(cb, result, @extra);    break;    case STATE_NO_FUTURE:    case STATE_PENDING:    // Rely on interpreter lock to add to failure_cbs before state changes    // again    failure_cbs += ({ ({ cb, @extra }) });    }    return this_program::this;    }    -  +  //! Query the set of active failure callbacks. +  //! +  //! @returns +  //! Returns an array with callback functions. +  //! +  //! @seealso +  //! @[on_failure()], @[query_success_callbacks()] +  array(function) query_failure_callbacks() +  { +  return column(failure_cbs, 0); +  } +     //! 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 f;    if (mixed err = catch (f = fun(val, @ctx)))    p->failure(err);    else