Clarisse 5.0 SP8 SDK
 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
const unsigned long & get_class_info_id () const
virtual bool is_kindof (const CoreClassInfo &cinfo) const
virtual const CoreClassInfoget_class_info () 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

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 ()
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);
// note that SysThreadTaskManager has a helper method to facilitate this:
task_manager.add_generic_task([=] (unsigned int) { /* do stuff... */ });

Constructor & Destructor Documentation

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


taskAnything which is assignable to a CoreFunction. 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)

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

thread_idtask thread ID.

Implements SysThreadTask.