pike.git / lib / modules / Concurrent.pmod

version» Context lines:

pike.git/lib/modules/Concurrent.pmod:7:      protected enum State {    STATE_PENDING = 0,    STATE_FULFILLED,    STATE_REJECTED,   };      protected Thread.Mutex mux = Thread.Mutex();   protected Thread.Condition cond = Thread.Condition();    + //! Global failure callback, called when a promise without failure + //! callback fails. This is useful to log exceptions, so they are not + //! just silently caught and ignored. + void on_failure(function(mixed, mixed ... : void) f) + { +  global_on_failure = f; + } + protected function(mixed, mixed ... : void) global_on_failure; +    //! Value that will be provided asynchronously   //! sometime in the future.   //!   //! @seealso   //! @[Promise]   class Future   {    mixed result = UNDEFINED;    State state;   
pike.git/lib/modules/Concurrent.pmod:468:    if (state) return;    unlocked_success(value);    key = 0;    }       protected void unlocked_failure(mixed value)    {    state = STATE_REJECTED;    result = value;    cond->broadcast(); +  if( !sizeof(failure_cbs) && global_on_failure ) +  call_out(global_on_failure, 0, value);    foreach(failure_cbs,    [function(mixed, mixed ...: void) cb,    array(mixed) extra]) {    if (cb) {    call_out(cb, 0, value, @extra);    }    }    }       //! Reject the @[Future] value.