ICF 3.0.5.47
Technical documentation of ICF Libraries
iproc::CTaskState Class Reference

Represent state of asynchronous operation. More...

#include <CTaskState.h>

Inherits istd::IPolymorphic.

Collaboration diagram for iproc::CTaskState:

Public Types

using Status = ITaskPromise::Status
 
typedef std::function< void(CTaskState::Status)> FinishedFn
 

Public Member Functions

 CTaskState (const CTaskState &)=delete
 
 CTaskState ()
 
 CTaskState (CTaskState &&state)
 
 CTaskState (CTaskState::Status state)
 Constructs this object using some final state.
 
 CTaskState (istd::TOptDelPtr< ITaskPromise > &&promisePtr)
 Constructs this object using promise of doing some operation in the future.
 
 ~CTaskState () override
 Destructor.
 
bool IsFinished () const
 Check, if this operation is finished.
 
Status GetStatus () const
 Get current state of operation.
 
void CallAfterFinished (FinishedFn handler, bool futureOnly=false)
 Add handler will be called once after the operation is finished.
 
void DoCancel ()
 Cancel this operation.
 
CTaskState::Status WaitForFinished (const double *periodPtr=nullptr, bool cancelOnTimeout=false)
 Wait for operation finished.
 
CTaskStateoperator= (const CTaskState &)=delete
 
CTaskStateoperator= (CTaskState &&state)
 
bool operator== (Status status) const
 
bool operator!= (Status status) const
 

Detailed Description

Represent state of asynchronous operation.

This implementation is fully reentrant.

Definition at line 27 of file CTaskState.h.

Member Typedef Documentation

◆ FinishedFn

Definition at line 31 of file CTaskState.h.

◆ Status

Definition at line 30 of file CTaskState.h.

Constructor & Destructor Documentation

◆ CTaskState() [1/5]

iproc::CTaskState::CTaskState ( const CTaskState & )
delete

◆ CTaskState() [2/5]

iproc::CTaskState::CTaskState ( )

◆ CTaskState() [3/5]

iproc::CTaskState::CTaskState ( CTaskState && state)

◆ CTaskState() [4/5]

iproc::CTaskState::CTaskState ( CTaskState::Status state)

Constructs this object using some final state.

Parameters
statefinal state, it cannot be iproc::ITaskPromise::Running.

◆ CTaskState() [5/5]

iproc::CTaskState::CTaskState ( istd::TOptDelPtr< ITaskPromise > && promisePtr)

Constructs this object using promise of doing some operation in the future.

Parameters
promisePtrpromise pointer object.

◆ ~CTaskState()

iproc::CTaskState::~CTaskState ( )
override

Destructor.

Member Function Documentation

◆ CallAfterFinished()

void iproc::CTaskState::CallAfterFinished ( FinishedFn handler,
bool futureOnly = false )

Add handler will be called once after the operation is finished.

The handlers will be called in order of adding. Note: this handler call may be done after synchronization method WaitForFinished is ready.

Parameters
handlerfunction will be called after task is finished.
futureOnlyif false and the opertion is already finished, the handler will be called. If it is true, than than the handler will be called only on the future finish.

◆ DoCancel()

void iproc::CTaskState::DoCancel ( )

Cancel this operation.

◆ GetStatus()

Status iproc::CTaskState::GetStatus ( ) const

Get current state of operation.

Returns
state value.

Referenced by operator!=(), and operator==().

◆ IsFinished()

bool iproc::CTaskState::IsFinished ( ) const

Check, if this operation is finished.

Returns
true, of the operation is ready (calculated, aborted, failed) or is still running.

◆ operator!=()

bool iproc::CTaskState::operator!= ( Status status) const
inline

Definition at line 143 of file CTaskState.h.

References GetStatus().

◆ operator=() [1/2]

CTaskState & iproc::CTaskState::operator= ( const CTaskState & )
delete

◆ operator=() [2/2]

CTaskState & iproc::CTaskState::operator= ( CTaskState && state)

◆ operator==()

bool iproc::CTaskState::operator== ( Status status) const
inline

Definition at line 137 of file CTaskState.h.

References GetStatus().

◆ WaitForFinished()

CTaskState::Status iproc::CTaskState::WaitForFinished ( const double * periodPtr = nullptr,
bool cancelOnTimeout = false )

Wait for operation finished.

Parameters
periodPtroptional waiting time in seconds.
cancelOnTimeoutdo cancel when timeout.
Returns
state after waiting. It can be iproc::ITaskPromise::Running only in waiting period was defined.

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

© Witold Gantzke and Kirill Lepskiy