You.i Engine
CYIAbstractFuture Class Reference

Detailed Description

Abstract base class for CYIFuture.

See also
CYIFuture

#include <thread/YiFuture.h>

Inheritance diagram for CYIAbstractFuture:

Public Member Functions

virtual ~CYIAbstractFuture ()
 
bool IsCancelled () const
 
bool IsCompleted () const
 
bool Cancel ()
 
bool CancelOrWait ()
 
bool Wait () const
 
bool Wait (uint64_t timeoutMs) const
 

Public Attributes

CYISignalpCancelled
 A signal triggered when this object is cancelled. More...
 

Protected Member Functions

 CYIAbstractFuture (std::shared_ptr< CYIFutureSharedStateBase > pSharedState)
 

Protected Attributes

std::shared_ptr< CYIFutureSharedStateBase > m_pSharedState
 

Friends

class CYITaskBase
 
template<typename T >
class CYITask
 

Constructor & Destructor Documentation

◆ ~CYIAbstractFuture()

virtual CYIAbstractFuture::~CYIAbstractFuture ( )
virtual

◆ CYIAbstractFuture()

CYIAbstractFuture::CYIAbstractFuture ( std::shared_ptr< CYIFutureSharedStateBase >  pSharedState)
protected

Member Function Documentation

◆ Cancel()

bool CYIAbstractFuture::Cancel ( )

Cancels this CYIFuture. Further attempts to Set() a value will fail.

If this object has an associated task, a cancellation attempt is made on that task.

Cancellation can fail if a value has already been assigned to this object, or if this object has already been cancelled. If this object has an associated task and that task has already started executing, cancellation will fail (but the task may be notified that cancellation was requested.)

The Cancelled signal is triggered if cancellation succeeds.

Note
Some tasks support asynchronous cancellation. When this object is used with an associated task, this function may return false and get cancelled at a later point when the associated task acknowledges the cancellation request.
Returns
Returns true if cancellation succeeded, false otherwise.

◆ CancelOrWait()

bool CYIAbstractFuture::CancelOrWait ( )

Cancels this CYIFuture. If this object has an associated task and that task is currently executing, this function will block until the task completes its execution or until the task gets cancelled.

After this function returns, an associated task is guaranteed to not execute subsequently (but may already have been executed).

See also
CYIAbstractFuture::Cancel()

◆ IsCancelled()

bool CYIAbstractFuture::IsCancelled ( ) const
Returns
Returns true if the Cancel() function has been called on this object.

◆ IsCompleted()

bool CYIAbstractFuture::IsCompleted ( ) const
Returns
Returns true if a value has been assigned to this object.

◆ Wait() [1/2]

bool CYIAbstractFuture::Wait ( ) const

Waits until a value has been assigned to this object, or until this object has been cancelled.

Note
Returns immediately if this object has been assigned a value or has been cancelled.
Warning
If no value gets assigned to this object, this function will wait forever.
Returns
Returns true if a value has been assigned to this object.

◆ Wait() [2/2]

bool CYIAbstractFuture::Wait ( uint64_t  timeoutMs) const

Waits until a value has been assigned to this object, until this object has been cancelled, or until the specified timeout is reached.

Note
Returns immediately if this object has been assigned a value or has been cancelled.
A return value of false can indicate either that this object has been cancelled or that the timeout value has been reached.
In some circumstances, this function may return before the timeout is reached, even if this object hasn't been cancelled and hasn't had a value assigned to it (e.g. in case of a 'spurious wakeup').
Returns
Returns true if a value has been assigned to this object.

Friends And Related Function Documentation

◆ CYITask

template<typename T >
friend class CYITask
friend

◆ CYITaskBase

friend class CYITaskBase
friend

Member Data Documentation

◆ m_pSharedState

std::shared_ptr<CYIFutureSharedStateBase> CYIAbstractFuture::m_pSharedState
protected

◆ pCancelled

CYISignal* CYIAbstractFuture::pCancelled

A signal triggered when this object is cancelled.


The documentation for this class was generated from the following file: