cocos2d-x  3.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
AsyncTaskPool Class Reference

#include <CCAsyncTaskPool.h>

Classes

class  ThreadTasks
 

Public Types

enum  TaskType { TASK_IO, TASK_NETWORK, TASK_OTHER, TASK_MAX_TYPE }
 
typedef std::function< void(void *)> TaskCallBack

Public Member Functions

void stopTasks (TaskType type)
 stop tasks More...
 
var stopTasks ( var type)
 stop tasks More...
 
local stopTasks ( local type)
 stop tasks More...
 
template<class F >
void enqueue (TaskType type, const TaskCallBack &callback, void *callbackParam, F &&f)
 enqueue a asynchronous task More...
 
template<class F >
var enqueue ( var type, var callback, var callbackParam, var f)
 enqueue a asynchronous task More...
 
template<class F >
local enqueue ( local type, local callback, local callbackParam, local f)
 enqueue a asynchronous task More...
 
 ~AsyncTaskPool ()

Static Public Member Functions

static AsyncTaskPoolgetInstance ()
 get instance More...
 
static void destoryInstance ()
 destroy instance More...
 
local destoryInstance ()
 destroy instance More...
 

Public Attributes

CC_CONSTRUCTOR_ACCESS __pad0__: AsyncTaskPool()

Protected Attributes

ThreadTasks _threadTasks [int(TaskType::TASK_MAX_TYPE)]
var _threadTasks ( var TASK_MAX_TYPE)
local _threadTasks ( local TASK_MAX_TYPE)

Static Protected Attributes

static AsyncTaskPools_asyncTaskPool
var s_asyncTaskPool
local s_asyncTaskPool

Member Typedef Documentation

typedef std::function<void(void*)>
TaskCallBack
local TaskCallBack

Member Enumeration Documentation

enum TaskType
strong
Enumerator
TASK_IO 
TASK_NETWORK 
TASK_OTHER 
TASK_MAX_TYPE 
var TaskType
strong
Enumerator
TASK_IO 
TASK_NETWORK 
TASK_OTHER 
TASK_MAX_TYPE 
local TaskType
strong
Enumerator
TASK_IO 
TASK_NETWORK 
TASK_OTHER 
TASK_MAX_TYPE 

Constructor & Destructor Documentation

var ~AsyncTaskPool ( )
local ~AsyncTaskPool ( )

Member Function Documentation

static void destoryInstance ( )
static

destroy instance

var destoryInstance ( )
static

destroy instance

local destoryInstance ( )
static

destroy instance

void enqueue ( AsyncTaskPool::TaskType  type,
const TaskCallBack callback,
void *  callbackParam,
F &&  f 
)
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
ftask can be lambda function
argstask parameters
var enqueue ( var  type,
var  callback,
var  callbackParam,
var  f 
)
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
ftask can be lambda function
argstask parameters
local enqueue ( local  type,
local  callback,
local  callbackParam,
local  f 
)
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
ftask can be lambda function
argstask parameters
static AsyncTaskPool* getInstance ( )
static

get instance

var getInstance ( )
static

get instance

local getInstance ( )
static

get instance

void stopTasks ( TaskType  type)
inline

stop tasks

Parameters
typetask type you want to stop
var stopTasks ( var  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

Member Data Documentation

ThreadTasks _threadTasks[int(TaskType::TASK_MAX_TYPE)]
protected
ThreadTasks _threadTasks[int(TaskType::TASK_MAX_TYPE)]
protected
ThreadTasks _threadTasks[int(TaskType::TASK_MAX_TYPE)]
protected
AsyncTaskPool* s_asyncTaskPool
staticprotected
var s_asyncTaskPool
staticprotected
local s_asyncTaskPool
staticprotected

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