pike.git / lib / modules / Concurrent.pmod

version» Context lines:

pike.git/lib/modules/Concurrent.pmod:298:    //! as arguments two and onwards when the callbacks are called.    //!    //! @returns    //! The new @[Future].    //!    //! @seealso    //! @[transform()], @[thencatch()]    //! @[on_success()], @[Promise.success()]    //! @[on_failure()], @[Promise.failure()]    //! @url{https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise@} -  inline this_program then(void|function(mixed, mixed ... : mixed) onfulfilled, +  this_program then(void|function(mixed, mixed ... : mixed) onfulfilled,    void|function(mixed, mixed ... : mixed) onrejected,    mixed ... extra) {    Promise p = Promise();    if (onfulfilled)    on_success(apply, p, onfulfilled, extra);    else    on_success(p->success);    if (onrejected)    on_failure(apply, p, onrejected, extra);    else
pike.git/lib/modules/Concurrent.pmod:511:    futures->on_success(try_success);    }   }      //! @returns   //! A @[Future] that represents the first   //! of the @expr{futures@} that completes.   //!   //! @seealso   //! @[race()] - Future first_completed(array(Future) futures) + variant Future first_completed(array(Future) futures)   {    Promise p = FirstCompleted(futures);    return p->future();   } -  + variant inline Future first_completed(Future ... futures) + { +  return first_completed(futures); + }      //! JavaScript Promise API equivalent of @[first_completed()].   //!   //! @seealso   //! @[first_completed()]   //! @url{https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise@} - inline Future race(array(Future) futures) + variant inline Future race(array(Future) futures)   {    return first_completed(futures);   } -  + variant inline Future race(Future ... futures) + { +  return first_completed(futures); + }      protected class Results   {    inherit Promise;       protected void create(array(Future) futures)    {    if (!sizeof(futures)) {    success(({}));    return;
pike.git/lib/modules/Concurrent.pmod:569:    key = 0;    success(results);    }   }      //! @returns   //! A @[Future] that represents the array of all the completed @expr{futures@}.   //!   //! @seealso   //! @[all()] - Future results(array(Future) futures) + variant Future results(array(Future) futures)   {    Promise p = Results(futures);    return p->future();   } -  + inline variant Future results(Future ... futures) + { +  return results(futures); + }      //! JavaScript Promise API equivalent of @[results()].   //!   //! @seealso   //! @[results()]   //! @url{https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise@}   inline variant Future all(array(Future) futures)   {    return results(futures);   }
pike.git/lib/modules/Concurrent.pmod:599:   //! @returns   //! A new @[Future] that has already failed for the specified @expr{reason@}.   //!   //! @seealso   //! @[Future.on_failure()], @[Promise.failure()]   //! @url{https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise@}   Future reject(mixed reason)   {    object p = Promise();    p->failure(reason); -  return p; +  return p->future();   }      //! @returns   //! A new @[Future] that has already been fulfilled with @expr{value@}   //! as result. If @expr{value@} is an object which already   //! has @[on_failure] and @[on_success] methods, return it unchanged.   //!   //! @note   //! This function can be used to ensure values are futures.   //!   //! @seealso   //! @[Future.on_success()], @[Promise.success()]   //! @url{https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise@}   Future resolve(mixed value)   {    if (objectp(value) && value->on_failure && value->on_success)    return value;    object p = Promise();    p->success(value); -  return p; +  return p->future();   }      //! Return a @[Future] that represents the array of mapping @[fun]   //! over the results of the completed @[futures].   Future traverse(array(Future) futures,    function(mixed, mixed ... : mixed) fun,    mixed ... extra)   {    return results(futures->map(fun, @extra));   }