pike.git / lib / modules / Concurrent.pmod

version» Context lines:

pike.git/lib/modules/Concurrent.pmod:79:    mixed result;    State state;       protected array(array(function(mixed, mixed ...: void)|mixed))    success_cbs = ({});    protected array(array(function(mixed, mixed ...: void)|mixed))    failure_cbs = ({});       protected Pike.Backend backend;    +  protected array timeout_call_out_handle; +     //! Set the backend to use for calling any callbacks.    //!    //! @note    //! This overides the mode set by @[use_backend()].    //!    //! @seealso    //! @[get_backend()], @[use_backend()]    void set_backend(Pike.Backend backend)    {    this::backend = backend;
pike.git/lib/modules/Concurrent.pmod:119:    //!    //! The default implementation calls @[cb] via the    //! backend set via @[set_backend()] (if any), and    //! otherwise falls back the the mode set by    //! @[use_backend()].    //!    //! @seealso    //! @[set_backend()], @[use_backend()]    protected void call_callback(function cb, mixed ... args)    { +  if (timeout_call_out_handle) { +  // Remove the timeout call_out, as it will not be relevant, +  // but holds a reference to us. +  (backend?backend->remove_call_out:remove_call_out) +  (timeout_call_out_handle); +  timeout_call_out_handle = UNDEFINED; +  }    if (backend) {    backend->call_out(cb, 0, @args);    } else {    callout(cb, 0, @args);    }    }       //! Wait for fulfillment and return the value.    //!    //! @throws
pike.git/lib/modules/Concurrent.pmod:613:    return then(0, onrejected, @extra);    }       //! Return a @[Future] that will either be fulfilled with the fulfilled    //! result of this @[Future], or be failed after @[seconds] have expired.    this_program timeout(int|float seconds)    {    Promise p = Promise();    on_failure(p->failure);    on_success(p->success); -  (backend?backend->call_out:call_out) +  if (timeout_call_out_handle) { +  // Remove the previous timeout call_out. +  (backend?backend->remove_call_out:remove_call_out) +  (timeout_call_out_handle); +  } +  timeout_call_out_handle = (backend?backend->call_out:call_out)    (p->try_failure, seconds, ({ "Timeout.\n", backtrace() }));    return p->future();    }       protected string _sprintf(int t)    {    return t=='O' && sprintf("%O(%s,%O)", this_program,    ([ STATE_NO_FUTURE : "no future",    STATE_PENDING : "pending",    STATE_REJECTED : "rejected",