21   _future_state(FS_pending) {
    49   _done_event = done_event;
    56 INLINE 
const std::string &AsyncFuture::
    57 get_done_event()
 const {
    68   nassertr_always(
done(), 
nullptr);
    85   ref_ptr = _result_ref.p();
   125   if (futures.empty()) {
   127     fut->_future_state = (AtomicAdjust::Integer)FS_finished;
   129   } 
else if (futures.size() == 1) {
   130     return futures[0].p();
   141 INLINE 
bool AsyncFuture::
   143   return set_future_state(FS_locked_pending);
   149 INLINE 
void AsyncFuture::
   150 unlock(FutureState new_state) {
   151   nassertv(new_state != FS_locked_pending);
   152   FutureState orig_state = (FutureState)
AtomicAdjust::set(_future_state, (AtomicAdjust::Integer)new_state);
   153   nassertv(orig_state == FS_locked_pending);
   162 INLINE 
bool AsyncFuture::
   163 set_future_state(FutureState state) {
   164   FutureState orig_state = (FutureState)
   167       (AtomicAdjust::Integer)FS_pending,
   168       (AtomicAdjust::Integer)state);
   170   while (orig_state == FS_locked_pending) {
   174       (AtomicAdjust::Integer)FS_pending,
   175       (AtomicAdjust::Integer)state);
   178   return orig_state == FS_pending;
   186   return _futures.size();
   194   nassertr(i < _futures.size(), 
nullptr);
   195   return _futures[i].p();
   203   nassertr(i < _futures.size(), 
nullptr);
   204   return _futures[i]->get_result();
 This class represents a thread-safe handle to a promised future result of an asynchronous operation,...
An optional parameter associated with an event.
AsyncFuture * get_future(size_t i) const
Returns the nth future that was passed into the constructor.
A base class for things which need to inherit from both TypedObject and from ReferenceCount.
This is an abstract class that all classes which use TypeHandle, and also provide virtual functions t...
static void force_yield()
Suspends the current thread for the rest of the current epoch.
AsyncFuture()
Initializes the future in the pending state.
TypedObject * get_result() const
Returns this future's result.
set_done_event
Sets the event name that will be triggered when the future finishes.
static AsyncFuture * gather(Futures futures)
Creates a new future that returns `done()` when all of the contained futures are done.
bool done() const
Returns true if the future is done or has been cancelled.
void set_result(std::nullptr_t)
Sets this future's result.
static Integer get(const Integer &var)
Atomically retrieves the snapshot value of the indicated variable.
A base class for things which need to inherit from both TypedWritable and from ReferenceCount.
Specific future that collects the results of several futures.
TypedWritableReferenceCount * get_ptr() const
Retrieves a pointer to the actual value stored in the parameter.
A base class for all things that want to be reference-counted.
size_t get_num_futures() const
Returns the number of futures that were passed to the constructor.
static Integer set(Integer &var, Integer new_value)
Atomically changes the indicated variable and returns the original value.
bool cancelled() const
Returns true if the future was cancelled.
static Integer compare_and_exchange(Integer &mem, Integer old_value, Integer new_value)
Atomic compare and exchange.