You.i Engine
CYIFuture< void > Class Template Reference

Detailed Description

template<>
class CYIFuture< void >

Void specialization of CYIFuture. This class doesn't hold a value, but instead simply holds a 'completed' state.

See also
CYIFuture<ResultType>

#include <thread/YiFuture.h>

Inheritance diagram for CYIFuture< void >:

Public Member Functions

 CYIFuture ()
 
void Reset ()
 
bool Set ()
 
template<typename Callable >
auto Then (Callable callable, CYIThreadPools::RunAsyncMode asyncMode=CYIThreadPools::RunAsyncMode::OnUIThread) -> CYIFuture< decltype(ReturnTypeOf< Callable >())>
 
- Public Member Functions inherited from CYIAbstractFuture
virtual ~CYIAbstractFuture ()
 
bool IsCancelled () const
 
bool IsCompleted () const
 
bool Cancel ()
 
bool CancelOrWait ()
 
bool Wait () const
 
bool Wait (uint64_t timeoutMs) const
 

Public Attributes

CYISignalpCompleted
 A signal triggered when this object is marked as completed. More...
 
- Public Attributes inherited from CYIAbstractFuture
CYISignalpCancelled
 A signal triggered when this object is cancelled. More...
 

Protected Member Functions

CYIFutureSharedStateGetCastSharedState ()
 A convenience function for getting the cast shared state pointer. More...
 
- Protected Member Functions inherited from CYIAbstractFuture
 CYIAbstractFuture (std::shared_ptr< CYIFutureSharedStateBase > pSharedState)
 

Additional Inherited Members

- Protected Attributes inherited from CYIAbstractFuture
std::shared_ptr< CYIFutureSharedStateBase > m_pSharedState
 

Constructor & Destructor Documentation

◆ CYIFuture()

CYIFuture< void >::CYIFuture ( )

Member Function Documentation

◆ GetCastSharedState()

CYIFutureSharedState* CYIFuture< void >::GetCastSharedState ( )
inlineprotected

A convenience function for getting the cast shared state pointer.

◆ Reset()

void CYIFuture< void >::Reset ( )

Resets this object to a blank slate, as if newly-initialized.

Note
Calling this function does not cancel an associated task. However, the task's completion will no longer result in a value being assigned to this object.

◆ Set()

bool CYIFuture< void >::Set ( )

Marks this future as completed.

The future can only be set as completed once, and cannot be done if the future has been cancelled. A successful marking will result in the Completed signal being triggered as well as threads blocked on calls to Wait to wake up.

Returns
Returns true if the assignement succeeded.

◆ Then()

template<typename Callable >
auto CYIFuture< void >::Then ( Callable  callable,
CYIThreadPools::RunAsyncMode  asyncMode = CYIThreadPools::RunAsyncMode::OnUIThread 
) -> CYIFuture< decltype(ReturnTypeOf< Callable >())>

Adds a continuation to this future. The continuation is executed once this future has been marked as completed.

The callable can optionally take a CYITaskBase pointer as input. This allows the Callable to detect and respond to cancellation requests.

By default, continuations run on the UI thread. This can be changed by passing a value to asyncMode.

Multiple continuations can be added to the same future object. They will be executed in the order in which they were added.

Note
The callable can optionally take a CYITaskBase pointer as input. This allows the Callable to detect and respond to cancellation requests.
If this CYIFuture has already been marked as completed when this function is called, the continuation is immediately executed.
The continuation is not executed if the future is cancelled. Continuations are executed even if the CYIFuture that they're created on is deleted.
Returns
A CYIFuture that holds the result of the continuation's execution.

Examples:

future.Then([]()
{
// Continuation code
future.Then([](CYITaskBase *pTask)
{
// Continuation code

Member Data Documentation

◆ pCompleted

CYISignal* CYIFuture< void >::pCompleted

A signal triggered when this object is marked as completed.


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