Branch: Tag:

2019-02-13

2019-02-13 09:52:09 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Concurrent.Future: Added internal function call_callback().

This makes it possible to adjust the way that callbacks are
called via overloading. The typical use case is for wanting
callbacks to be called by some other thread than the backend.

81:    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
124:    {    switch (state) {    case STATE_FULFILLED: -  callout(cb, 0, result, @extra); +  call_callback(cb, result, @extra);    break;    case STATE_NO_FUTURE:    case STATE_PENDING:
154:    {    switch (state) {    case STATE_REJECTED: -  callout(cb, 0, result, @extra); +  call_callback(cb, result, @extra);    break;    case STATE_NO_FUTURE:    case STATE_PENDING:
776:    {    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