pike.git / lib / modules / Concurrent.pmod

version» Context lines:

pike.git/lib/modules/Concurrent.pmod:74:   class Future   {    mixed result;    State state;       protected array(array(function(mixed, mixed ...: void)|mixed))    success_cbs = ({});    protected array(array(function(mixed, mixed ...: void)|mixed))    failure_cbs = ({});    +  //! Call a callback function. +  //! +  //! @param cb +  //! Callback function to call. +  //! +  //! @param args +  //! Arguments to call @[cb] with. +  protected void call_callback(function cb, mixed ... args) +  { +  callout(cb, 0, @args); +  } +     //! Wait for fulfillment and return the value.    //!    //! @throws    //! Throws on rejection.    mixed get()    {    State s = state;    mixed res = result;    if (!s) {    Thread.MutexKey key = mux->lock();
pike.git/lib/modules/Concurrent.pmod:117:    //!    //! @note    //! @[cb] will always be called from the main backend.    //!    //! @seealso    //! @[on_failure()]    this_program on_success(function(mixed, mixed ... : void) cb, mixed ... extra)    {    switch (state) {    case STATE_FULFILLED: -  callout(cb, 0, result, @extra); +  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;    }   
pike.git/lib/modules/Concurrent.pmod:147:    //!    //! @note    //! @[cb] will always be called from the main backend.    //!    //! @seealso    //! @[on_success()]    this_program on_failure(function(mixed, mixed ... : void) cb, mixed ... extra)    {    switch (state) {    case STATE_REJECTED: -  callout(cb, 0, result, @extra); +  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;    }   
pike.git/lib/modules/Concurrent.pmod:769:    if (state <= STATE_PENDING)    {    state = newstate;    result = value;    key = 0;    cond->broadcast();    if (sizeof(cbs))    {    foreach(cbs; ; array cb)    if (cb) -  callout(cb[0], 0, value, @cb[1..]); +  call_callback(cb[0], value, @cb[1..]);    }    else if (globalfailure) -  callout(globalfailure, 0, value); +  call_callback(globalfailure, value);    failure_cbs = success_cbs = 0; // Free memory and references    }    else    {    key = 0;    if (!try)    error("Promise has already been finalised.\n");    }    return this_program::this;    }