Abstract base class for CYIFuture.
- See also
- CYIFuture
#include <thread/YiFuture.h>
◆ ~CYIAbstractFuture()
virtual CYIAbstractFuture::~CYIAbstractFuture |
( |
| ) |
|
|
virtual |
◆ CYIAbstractFuture()
CYIAbstractFuture::CYIAbstractFuture |
( |
std::shared_ptr< CYIFutureSharedStateBase > |
pSharedState | ) |
|
|
protected |
◆ 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.
◆ CYITask
◆ CYITaskBase
◆ m_pSharedState
std::shared_ptr<CYIFutureSharedStateBase> CYIAbstractFuture::m_pSharedState |
|
protected |
◆ pCancelled
A signal triggered when this object is cancelled.
The documentation for this class was generated from the following file: