pike.git / lib / modules / Concurrent.pmod

version» Context lines:

pike.git/lib/modules/Concurrent.pmod:1119:    {    if (!state)    try_failure(({ "Promise broken.\n", backtrace() }));    }   }      //! @returns   //! A @[Future] that represents the first   //! of the @expr{futures@} that completes.   //! + //! @note + //! The returned @[Future] does NOT have any state (eg backend) + //! propagated from the @[futures]. This must be done by hand. + //!   //! @seealso   //! @[race()], @[Promise.first_completed()]   variant Future first_completed(array(Future) futures)   {    return Promise()->depend(futures)->first_completed()->future();   }   variant inline Future first_completed(Future ... futures)   {    return first_completed(futures);   }      //! JavaScript Promise API equivalent of @[first_completed()].   //! -  + //! @note + //! The returned @[Future] does NOT have any state (eg backend) + //! propagated from the @[futures]. This must be done by hand. + //!   //! @seealso   //! @[first_completed()], @[Promise.first_completed()]   //! @url{https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise@}   variant inline Future race(array(Future) futures)   {    return first_completed(futures);   }   variant inline Future race(Future ... futures)   {    return first_completed(futures);   }      //! @returns   //! A @[Future] that represents the array of all the completed @expr{futures@}.   //! -  + //! @note + //! The returned @[Future] does NOT have any state (eg backend) + //! propagated from the @[futures]. This must be done by hand. + //!   //! @seealso   //! @[all()], @[Promise.depend()]   variant Future results(array(Future) futures)   {    if(!sizeof(futures))    return resolve(({}));       return Promise()->depend(futures)->future();   }   inline variant Future results(Future ... futures)   {    return results(futures);   }      //! JavaScript Promise API equivalent of @[results()].   //! -  + //! @note + //! The returned @[Future] does NOT have any state (eg backend) + //! propagated from the @[futures]. This must be done by hand. + //!   //! @seealso   //! @[results()], @[Promise.depend()]   //! @url{https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise@}   inline variant Future all(array(Future) futures)   {    return results(futures);   }   inline variant Future all(Future ... futures)   {    return results(futures);   }      //! @returns   //! A new @[Future] that has already failed for the specified @expr{reason@}.   //! -  + //! @note + //! The returned @[Future] does NOT have a backend set. + //!   //! @seealso   //! @[Future.on_failure()], @[Promise.failure()]   //! @url{https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise@}   Future reject(mixed reason)   {    return Promise()->failure(reason)->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.   //! -  + //! @note + //! The returned @[Future] does NOT have a backend set. + //!   //! @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;    return Promise()->success(value)->future();   }      //! Return a @[Future] that represents the array of mapping @[fun]   //! over the results of the completed @[futures]. -  + //! + //! @note + //! The returned @[Future] does NOT have any state (eg backend) + //! propagated from the @[futures]. This must be done by hand.   Future traverse(array(Future) futures,    function(mixed, mixed ... : mixed) fun,    mixed ... extra)   {    return results(futures->map(fun, @extra));   }      //! Return a @[Future] that represents the accumulated results of   //! applying @[fun] to the results of the @[futures] in turn.   //!
pike.git/lib/modules/Concurrent.pmod:1232:   //! value, and any further from @[extra].   //!   //! @note   //! If @[fun] throws an error it will fail the @[Future].   //!   //! @note   //! @[fun] may be called in any order, and will be called   //! once for every @[Future] in @[futures], unless one of   //! calls fails in which case no further calls will be   //! performed. + //! + //! @note + //! The returned @[Future] does NOT have any state (eg backend) + //! propagated from the @[futures]. This must be done by hand.   Future fold(array(Future) futures,    mixed initial,    function(mixed, mixed, mixed ... : mixed) fun,    mixed ... extra)   {    return Promise()->depend(futures)->fold(initial, fun, extra)->future();   }