You.i Engine
CYIStaticTask< ResultType > Class Template Reference

Detailed Description

template<typename ResultType = void>
class CYIStaticTask< ResultType >

An utility class used to create a task from a static function.

Deprecated:
This class has been deprecated and may be removed in a future release. The CYICallableTask class should be used instead (or one of the YiMakeTask helper functions).

The provided static function can be either a 'raw' static function, or a static member function of a given class.

Between 0 and 4 function parameters can be used with this class. A copy of the function parameter values is stored within the CYIStaticTask object.

The return type of the static function must match the templated type of the static task. Void functions are supported (use a CYIStaticTask<> when creating the static task).

Note
When passing function parameters to the Static Task constructor, it is important to use exact types. Template type inference (e.g. int32_t to int64_t or "foo" to CYIString("foo")) does not always work and sometimes requires specific casting or construction.
Warning
Passing raw pointers to tasks is not recommended as ownership of the raw pointer and lifetime of the pointed-to memory is difficult to manage.

Sample usage:

CYITask<CYIString> *pMyTask = new CYIStaticTask(myFutureObj, &MyClass::MyStaticFunction, 42, CYIString("foo"));
Template Parameters
ResultTypethe return type of the static function.
See also
CYITask<ResultType>

#include <thread/YiStaticTask.h>

Inheritance diagram for CYIStaticTask< ResultType >:

Public Member Functions

 CYIStaticTask (CYIFuture< ResultType > future, ResultType(*const pFunc)())
 
template<typename P1 >
 CYIStaticTask (CYIFuture< ResultType > future, ResultType(*const pFunc)(P1), P1 funcParam1)
 
template<typename P1 , typename P2 >
 CYIStaticTask (CYIFuture< ResultType > future, ResultType(*const pFunc)(P1, P2), P1 funcParam1, P2 funcParam2)
 
template<typename P1 , typename P2 , typename P3 >
 CYIStaticTask (CYIFuture< ResultType > future, ResultType(*const pFunc)(P1, P2, P3), P1 funcParam1, P2 funcParam2, P3 funcParam3)
 
template<typename P1 , typename P2 , typename P3 , typename P4 >
 CYIStaticTask (CYIFuture< ResultType > future, ResultType(*const pFunc)(P1, P2, P3, P4), P1 funcParam1, P2 funcParam2, P3 funcParam3, P4 funcParam4)
 
 CYIStaticTask (ResultType(*const pFunc)())
 
template<typename P1 >
 CYIStaticTask (ResultType(*const pFunc)(P1), P1 funcParam1)
 
template<typename P1 , typename P2 >
 CYIStaticTask (ResultType(*const pFunc)(P1, P2), P1 funcParam1, P2 funcParam2)
 
template<typename P1 , typename P2 , typename P3 >
 CYIStaticTask (ResultType(*const pFunc)(P1, P2, P3), P1 funcParam1, P2 funcParam2, P3 funcParam3)
 
template<typename P1 , typename P2 , typename P3 , typename P4 >
 CYIStaticTask (ResultType(*const pFunc)(P1, P2, P3, P4), P1 funcParam1, P2 funcParam2, P3 funcParam3, P4 funcParam4)
 
virtual ~CYIStaticTask ()
 
- Public Member Functions inherited from CYITask< ResultType >
 CYITask ()
 
 CYITask (CYIFuture< ResultType > future)
 
bool SetFuture (CYIFuture< ResultType > future)
 
- Public Member Functions inherited from CYITaskBase
virtual ~CYITaskBase ()
 
State GetState () const
 
bool MarkPendingExecution ()
 
void RequestCancellation ()
 
bool IsCancellationRequested () const
 
void SetCancellationRequestSucceeded ()
 
bool IsCancellationRequestSucceeded () const
 
bool Execute ()
 

Protected Member Functions

virtual ResultType Run () override
 

Additional Inherited Members

- Public Types inherited from CYITaskBase
enum  State : uint8_t {
  State::New,
  State::PendingExecution,
  State::Executing,
  State::Completed,
  State::Cancelled
}
 

Constructor & Destructor Documentation

◆ CYIStaticTask() [1/10]

template<typename ResultType = void>
CYIStaticTask< ResultType >::CYIStaticTask ( CYIFuture< ResultType >  future,
ResultType(*)()  pFunc 
)

Creates a task from pFunc, which is a static function. Creates an association with future.

◆ CYIStaticTask() [2/10]

template<typename ResultType = void>
template<typename P1 >
CYIStaticTask< ResultType >::CYIStaticTask ( CYIFuture< ResultType >  future,
ResultType(*)(P1)  pFunc,
P1  funcParam1 
)

Creates a task from pFunc, which is a static function. Creates an association with future. funcParam1 is passed to the static function.

◆ CYIStaticTask() [3/10]

template<typename ResultType = void>
template<typename P1 , typename P2 >
CYIStaticTask< ResultType >::CYIStaticTask ( CYIFuture< ResultType >  future,
ResultType(*)(P1, P2)  pFunc,
P1  funcParam1,
P2  funcParam2 
)

Creates a task from pFunc, which is a static function. Creates an association with future. funcParam1, funcParam2 are passed to the static function.

◆ CYIStaticTask() [4/10]

template<typename ResultType = void>
template<typename P1 , typename P2 , typename P3 >
CYIStaticTask< ResultType >::CYIStaticTask ( CYIFuture< ResultType >  future,
ResultType(*)(P1, P2, P3)  pFunc,
P1  funcParam1,
P2  funcParam2,
P3  funcParam3 
)

Creates a task from pFunc, which is a static function. Creates an association with future. funcParam1, funcParam2, funcParam3 are passed to the static function.

◆ CYIStaticTask() [5/10]

template<typename ResultType = void>
template<typename P1 , typename P2 , typename P3 , typename P4 >
CYIStaticTask< ResultType >::CYIStaticTask ( CYIFuture< ResultType >  future,
ResultType(*)(P1, P2, P3, P4)  pFunc,
P1  funcParam1,
P2  funcParam2,
P3  funcParam3,
P4  funcParam4 
)

Creates a task from pFunc, which is a static function. Creates an association with future. funcParam1, funcParam2, funcParam3, funcParam4 are passed to the static function.

◆ CYIStaticTask() [6/10]

template<typename ResultType = void>
CYIStaticTask< ResultType >::CYIStaticTask ( ResultType(*)()  pFunc)

Creates a task from pFunc, which is a static function.

◆ CYIStaticTask() [7/10]

template<typename ResultType = void>
template<typename P1 >
CYIStaticTask< ResultType >::CYIStaticTask ( ResultType(*)(P1)  pFunc,
P1  funcParam1 
)

Creates a task from pFunc, which is a static function. funcParam1 is passed to the static function.

◆ CYIStaticTask() [8/10]

template<typename ResultType = void>
template<typename P1 , typename P2 >
CYIStaticTask< ResultType >::CYIStaticTask ( ResultType(*)(P1, P2)  pFunc,
P1  funcParam1,
P2  funcParam2 
)

Creates a task from pFunc, which is a static function. funcParam1, funcParam2 are passed to the static function.

◆ CYIStaticTask() [9/10]

template<typename ResultType = void>
template<typename P1 , typename P2 , typename P3 >
CYIStaticTask< ResultType >::CYIStaticTask ( ResultType(*)(P1, P2, P3)  pFunc,
P1  funcParam1,
P2  funcParam2,
P3  funcParam3 
)

Creates a task from pFunc, which is a static function. funcParam1, funcParam2, funcParam3 are passed to the static function.

◆ CYIStaticTask() [10/10]

template<typename ResultType = void>
template<typename P1 , typename P2 , typename P3 , typename P4 >
CYIStaticTask< ResultType >::CYIStaticTask ( ResultType(*)(P1, P2, P3, P4)  pFunc,
P1  funcParam1,
P2  funcParam2,
P3  funcParam3,
P4  funcParam4 
)

Creates a task from pFunc, which is a static function. funcParam1, funcParam2, funcParam3, funcParam4 are passed to the static function.

◆ ~CYIStaticTask()

template<typename ResultType = void>
virtual CYIStaticTask< ResultType >::~CYIStaticTask ( )
virtual

Member Function Documentation

◆ Run()

template<typename ResultType = void>
virtual ResultType CYIStaticTask< ResultType >::Run ( )
overrideprotectedvirtual

Executes the static function to which this object has a reference, using the parameters provided during construction of this static task.

Returns
The result of the execution of the static function.

Implements CYITask< ResultType >.


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