Clarisse 4.0 SP10 SDK  4.0.0.0.10
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Protected Member Functions | List of all members
SysThreadTaskGeneric Class Reference
Inheritance diagram for SysThreadTaskGeneric:
SysThreadTask CoreBaseObject CoreBaseType

Public Member Functions

template<typename T >
 SysThreadTaskGeneric (T &&task)
 
- Public Member Functions inherited from SysThreadTask
SysThreadTaskManagerget_task_manager () const
 
const bool & is_auto_deleted () const
 
const bool & is_preemptible () const
 
void set_auto_delete (const bool &auto_delete)
 
- Public Member Functions inherited from CoreBaseObject
bool is_kindof (const CoreBaseObject &object) const
 
virtual size_t get_memory_size () const
 
CoreString get_class_info_name () const
 
CoreString get_class_interface () const
 
const unsigned long & get_class_info_id () const
 
bool is_kindof (const CoreClassInfo &cinfo) const
 
virtual const CoreClassInfoget_class_info () const
 
bool operator== (const CoreBaseObject &obj) const
 
template<class T >
T * cast ()
 
template<class T >
const T * cast () const
 
- Public Member Functions inherited from CoreBaseType
bool is_kindof (const CoreClassInfo &cinfo) const
 
bool operator== (const CoreBaseType &obj) const
 

Protected Member Functions

void execution_entry (const unsigned int &thread_id) final
 

Additional Inherited Members

- Static Public Member Functions inherited from CoreBaseObject
static const CoreClassInfoclass_info ()
 
static bool ___class_destructor__ (void *instance, const bool &is_array)
 
template<class T >
static T * cast (CoreBaseObject *object)
 
template<class T >
static const T * cast (const CoreBaseObject *object)
 

Detailed Description

Generic task to be used with the thread task manager, allowing task code to be created at the call site (using lambdas for instance)

// create a task manager
SysThreadTaskManager task_manager;
// add add task using a lambda (for instance)
for (int i = 0; i < 10; ++i) {
task_manager.add_task(*(new SysThreadTaskGeneric([=] (unsigned int) {
// do some stuff here. You have access to the outer scope
// via lambda capture, but everything's multithreaded inside
})), true, false);
}

Constructor & Destructor Documentation

template<typename T >
SysThreadTaskGeneric::SysThreadTaskGeneric ( T &&  task)
inline

Constructor

Parameters
taskAnything which is assignable to a std::function. This can be a lambda or the result of a call to std::bind, etc. The callable must have the signature void (unsigned int): when the task is executed, the thread id will be passed to the task as an argument.

Member Function Documentation

void SysThreadTaskGeneric::execution_entry ( const unsigned int &  thread_id)
inlinefinalprotectedvirtual

Execution entry point of the task. This were the task work must be implemented.

Parameters
thread_idtask thread ID.

Implements SysThreadTask.