Branch: Tag:

2019-02-28

2019-02-28 15:02:12 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Concurrent.Future: Added wait().

This differs from get() in that it will not throw on failure.

175:    }    }    -  //! Wait for fulfillment and return the value. +  //! Wait for fulfillment.    //! -  //! @throws -  //! Throws on rejection. -  mixed get() +  //! @seealso +  //! @[get()] +  this_program wait()    { -  State s = state; -  mixed res = result; -  if (!s) { +  if (state <= STATE_PENDING) {    Thread.MutexKey key = mux->lock();    while (state <= STATE_PENDING) {    cond->wait(key);    } -  +  }    -  s = state; -  res = result; +  return this;    }    -  if (s >= STATE_REJECTED) { -  throw(res); +  //! Wait for fulfillment and return the value. +  //! +  //! @throws +  //! Throws on rejection. +  //! +  //! @seealso +  //! @[wait()] +  mixed get() +  { +  wait(); +  +  if (state >= STATE_REJECTED) { +  throw(result);    } -  return res; +  return result;    }       //! Register a callback that is to be called on fulfillment.
851:    return ::on_failure(cb, @extra);    }    +  Future wait() +  { +  if (_astate) +  _astate->materialise(); +  return ::wait(); +  } +     mixed get()    {    if (_astate)