Branch: Tag:

2017-11-27

2017-11-27 14:57:37 by Stephen R. van den Berg <srb@cuci.nl>

Concurrent: Cleanup.

47:    State s = state;    mixed res = result;    if (!s) { -  object key = mux->lock(); +  Thread.MutexKey key = mux->lock();    while (!state) {    cond->wait(key);    }
80:    //! @[on_failure()]    this_program on_success(function(mixed, mixed ... : void) cb, mixed ... extra)    { -  object key = mux->lock(); +  Thread.MutexKey key = mux->lock();       if (state == STATE_FULFILLED) {    call_out(cb, 0, result, @extra);
111:    //! @[on_success()]    this_program on_failure(function(mixed, mixed ... : void) cb, mixed ... extra)    { -  object key = mux->lock(); +  Thread.MutexKey key = mux->lock();       if (state == STATE_REJECTED) {    call_out(cb, 0, result, @extra);
347:    //! @[results()]    this_program zip(this_program ... others)    { -  if (!sizeof(others)) return this_program::this; -  return results(({ this_program::this }) + others); +  return sizeof(others) +  ? results(({ this_program::this }) + others) +  : this_program::this;    }       //! JavaScript Promise API close but not identical equivalent
493:    private void cb_failure(mixed value, int idx) {    Promise p; // Cache it, to cover a failure race    if (p = promise) { -  object key = mux->lock(); +  Thread.MutexKey key = mux->lock();    do {    if (!p->state) {    ++failed;
523:    private void cb_success(mixed value, int idx) {    Promise p; // Cache it, to cover a failure race    if (p = promise) { -  object key = mux->lock(); +  Thread.MutexKey key = mux->lock();    do {    if (!p->state) {    ++succeeded;
633:    void success(mixed value)    {    if (state) error("Promise has already been finalised.\n"); -  object key = mux->lock(); +  Thread.MutexKey key = mux->lock();    if (state) error("Promise has already been finalised.\n");    unlocked_success(value);    key = 0;
653:    void try_success(mixed value)    {    if (state) return; -  object key = mux->lock(); +  Thread.MutexKey key = mux->lock();    if (state) return;    unlocked_success(value);    key = 0;
692:    void failure(mixed value)    {    if (state) error("Promise has already been finalised.\n"); -  object key = mux->lock(); +  Thread.MutexKey key = mux->lock();    if (state) error("Promise has already been finalised.\n");    unlocked_failure(value);    key = 0;
712:    void try_failure(mixed value)    {    if (state) return; -  object key = mux->lock(); +  Thread.MutexKey key = mux->lock();    if (state) return;    unlocked_failure(value);    }
728:    //! from a new @[Promise] which is implictly added to the dependency list.    //!    //! @param futures -  //! The list of @expr{futures@} we want to add to the list we depend on. +  //! The list of @expr{futures@} we want to add to the list we depend upon.    //!    //! @returns    //! The new @[Promise].
914:   //! @[all()], @[Promise.depend()]   variant Future results(array(Future) futures)   { -  Promise p = Promise(); -  p->depend(futures); -  return p->future(); +  return Promise()->depend(futures)->future();   }   inline variant Future results(Future ... futures)   {
945:   //! @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->future(); +  return Promise()->failure(reason)->future();   }      //! @returns
963:   //! @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->future(); +  return objectp(value) && value->on_failure && value->on_success +  ? value +  : Promise()->success(value)->future();   }      //! Return a @[Future] that represents the array of mapping @[fun]
1003:    function(mixed, mixed, mixed ... : mixed) fun,    mixed ... extra)   { -  Promise p = Promise(); -  p->depend(futures); -  p->fold(initial, fun, extra); -  return p->future(); +  return Promise()->depend(futures)->fold(initial, fun, extra)->future();   }