Abstract base class for CYIFuture.
- See also
- CYIFuture<ResultType>
#include <thread/YiFuture.h>
|
| void | ExclusiveLock () const |
| | Locks both this object and the associated task (if it exists). More...
|
| |
| void | ExclusiveUnlock () const |
| | Unlocks both this object and the associated task (if it exists). More...
|
| |
| void | NotifyStateChanged () const |
| | Notify waiters (e.g. threads blocked on calls to Wait, Get or Take) of state change. More...
|
| |
| bool | SetTask (CYITaskBase *pTask) |
| | Sets the task asssociated with this object to the provided task. Returns true if the task was associated successfully, false otherwise. Has no effect if a task has already been assigned, or if this future has been cancelled or had a value assigned already. More...
|
| |
| void | DisconnectFromTask () |
| | Removes the task reference, if it exists. If an associated task exists, an attempt is made at cancelling it. More...
|
| |
| bool | SetCancelledNonLocking () |
| | Sets the 'cancelled' flag on this object, if it hasn't been done already and the future hasn't had a value assigned to it. Will awaken all waiters if the cancellation was successful (and will trigger the Cancelled signal). Returns false if the future could not be cancelled. The caller must have m_mutex locked. More...
|
| |
| bool | WaitNonLocking () const |
| | Equivalent to the Wait() function, but the caller must have m_mutex locked. More...
|
| |
| bool | WaitNonLocking (uint64_t uTimeoutMs) const |
| | Equivalent to the Wait() function, but the caller must have m_mutex locked. More...
|
| |
| bool | CancelInternal (bool bWait) |
| |
| virtual CYIAbstractFuture::~CYIAbstractFuture |
( |
| ) |
|
|
virtual |
| 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.
| bool CYIAbstractFuture::CancelInternal |
( |
bool |
bWait | ) |
|
|
protected |
| 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
- bool CYIAbstractFuture::Cancel()
| void CYIAbstractFuture::DisconnectFromTask |
( |
| ) |
|
|
protected |
Removes the task reference, if it exists. If an associated task exists, an attempt is made at cancelling it.
| void CYIAbstractFuture::ExclusiveLock |
( |
| ) |
const |
|
protected |
Locks both this object and the associated task (if it exists).
| void CYIAbstractFuture::ExclusiveUnlock |
( |
| ) |
const |
|
protected |
Unlocks both this object and the associated task (if it exists).
| bool CYIAbstractFuture::IsCancelled |
( |
| ) |
const |
- Returns
- Returns true if the Cancel() function has been called on this object.
| bool CYIAbstractFuture::IsCompleted |
( |
| ) |
const |
- Returns
- Returns true if a value has been assigned to this object.
| void CYIAbstractFuture::NotifyStateChanged |
( |
| ) |
const |
|
protected |
Notify waiters (e.g. threads blocked on calls to Wait, Get or Take) of state change.
| bool CYIAbstractFuture::SetCancelledNonLocking |
( |
| ) |
|
|
protected |
Sets the 'cancelled' flag on this object, if it hasn't been done already and the future hasn't had a value assigned to it. Will awaken all waiters if the cancellation was successful (and will trigger the Cancelled signal). Returns false if the future could not be cancelled. The caller must have m_mutex locked.
Sets the task asssociated with this object to the provided task. Returns true if the task was associated successfully, false otherwise. Has no effect if a task has already been assigned, or if this future has been cancelled or had a value assigned already.
| 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.
| bool CYIAbstractFuture::Wait |
( |
uint64_t |
uTimeoutMs | ) |
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.
| bool CYIAbstractFuture::WaitNonLocking |
( |
| ) |
const |
|
protected |
| bool CYIAbstractFuture::WaitNonLocking |
( |
uint64_t |
uTimeoutMs | ) |
const |
|
protected |
Equivalent to the Wait() function, but the caller must have m_mutex locked.
- See also
- CYIFuture::Wait(uint64_t uTimeoutMs)
A signal triggered when this object is cancelled.
| CYISignal CYIAbstractFuture::ExecutionStarted |
A signal triggered when an associated task begins execution.
The documentation for this class was generated from the following file: