Cocos2d-x  v3.17
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Groups Pages
AsyncTaskPool Class Reference

This class allows to perform background operations without having to manipulate threads. More...

Public Member Functions

void stopTasks (TaskType type)
 Stop tasks. More...
 
void enqueue (TaskType type, TaskCallBack callback, void *callbackParam, std::function< void()> task)
 Enqueue a asynchronous task. More...
 
void enqueue (AsyncTaskPool::TaskType type, std::function< void()> task)
 Enqueue a asynchronous task. More...
 

Static Public Member Functions

static AsyncTaskPoolgetInstance ()
 Returns the shared instance of the async task pool.
 
static void destroyInstance ()
 Destroys the async task pool.
 
static void destoryInstance ()

Detailed Description

This class allows to perform background operations without having to manipulate threads.

Member Function Documentation

static void destoryInstance ( )
inlinestatic
local destoryInstance ( )
inlinestatic
void stopTasks ( TaskType  type)
inline

Stop tasks.

Parameters
typeTask type you want to stop.
local stopTasks ( local  type)
inline

Stop tasks.

Parameters
typeTask type you want to stop.
void enqueue ( AsyncTaskPool::TaskType  type,
TaskCallBack  callback,
void *  callbackParam,
std::function< void()>  task 
)
inline

Enqueue a asynchronous task.

Parameters
typetask type is io task, network task or others, each type of task has a thread to deal with it.
callbackcallback when the task is finished. The callback is called in the main thread instead of task thread.
callbackParamparameter used by the callback.
tasktask can be lambda function to be performed off thread.
void enqueue ( AsyncTaskPool::TaskType  type,
std::function< void()>  task 
)
inline

Enqueue a asynchronous task.

Parameters
typetask type is io task, network task or others, each type of task has a thread to deal with it.
tasktask can be lambda function to be performed off thread.

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