Lockless Task Scheduler  v1.0a
A lockless task scheduler
Classes | Public Types | Public Member Functions | Public Attributes | Protected Member Functions | List of all members
task_scheduler::base_task< TMemInterface > Class Template Referenceabstract

Class base_task. More...

#include <task.h>

Inheritance diagram for task_scheduler::base_task< TMemInterface >:
Inheritance graph
[legend]
Collaboration diagram for task_scheduler::base_task< TMemInterface >:
Collaboration graph
[legend]

Classes

struct  debug_container
 Struct debug_container More...
 
struct  persistent_container
 Struct persistent_container More...
 
struct  transient_container
 Struct transient_container More...
 

Public Types

enum  priority_selector {
  realtime, high, normal, low,
  num_priority
}
 Enum priority_selector More...
 
typedef base_task< TMemInterface > task_type
 
typedef base_thread< TMemInterface > thread_type
 
typedef base_task_graph< TMemInterface > task_graph_type
 
typedef base_sub_graph< task_type, TMemInterface > sub_graph_type
 
typedef std::basic_string< tchar_t, std::char_traits< tchar_t >, stl_allocator< tchar_t, TMemInterface > > string_type
 
typedef std::vector< string_type, stl_allocator< string_type, TMemInterface > > string_vector
 
typedef std::vector< task_type *, stl_allocator< task_type *, TMemInterface > > task_vector
 
typedef base_thread_pool< TMemInterface > thread_pool
 
typedef std::function< void() > function_type
 
typedef int64_t rank_type
 
typedef std::vector< function_type > task_work_vector
 
typedef thread_index_t< TMemInterface > thread_index_type
 
typedef lock_free_node_dispenser< function_type *, TMemInterface > work_memory_allocator_type
 
typedef lock_free_queue< multi_producer_multi_consumer< function_type *, TMemInterface, work_memory_allocator_type >, function_type *, TMemInterface, work_memory_allocator_type *> work_queue_type
 

Public Member Functions

 base_task (task_graph_type &_task_graph)
 Initializes a new instance of the base_task class. More...
 
virtual ~base_task ()
 Finalizes an instance of the base_task class. More...
 
void set_thread_affinity (thread_mask_int_t _mask)
 Sets the thread affinity. More...
 
void set_thread_exclusion (thread_mask_int_t _mask)
 Sets the thread exclusion. More...
 
void set_num_workers (thread_num_t _num_workers)
 Sets the number workers. More...
 
void set_num_workers (percentage_t _percentage_workers)
 Sets the number workers. More...
 
void kick_dependent_tasks ()
 Kicks the dependent tasks. More...
 
bool add_task_parallel_work (function_type _work_function)
 Adds the task parallel work. More...
 
bool link_task (task_type *_next_task)
 Links the task. More...
 
bool operator() ()
 Operator()s this instance. More...
 
virtual thread_num_t get_recommended_num_workers ()
 Gets the best number of workers for the task every frame More...
 

Public Attributes

debug_container debug
 The debug More...
 
transient_container transient
 The transient More...
 
persistent_container persistent
 The persistent More...
 
task_graph_typetask_graph
 The task graph More...
 
thread_unsafe_access_storage add_task_parallel_work_detector
 The add task parallel work detector More...
 

Protected Member Functions

virtual bool run ()=0
 Calls the working function internally More...
 
virtual void before_scheduled (thread_num_t _scheduled_on_num_workers)
 Callback is called when a task is scheduled More...
 
virtual void after_run ()
 Callback is called after a task is run More...
 

Detailed Description

template<class TMemInterface>
class task_scheduler::base_task< TMemInterface >

Class base_task.

See also
TMemInterface

Member Enumeration Documentation

◆ priority_selector

template<class TMemInterface >
enum task_scheduler::base_task::priority_selector

Enum priority_selector

Constructor & Destructor Documentation

◆ base_task()

template<class TMemInterface >
task_scheduler::base_task< TMemInterface >::base_task ( task_graph_type _task_graph)

Initializes a new instance of the base_task class.

Parameters
_task_graphThe task graph.

◆ ~base_task()

template<class TMemInterface >
task_scheduler::base_task< TMemInterface >::~base_task ( )
virtual

Finalizes an instance of the base_task class.

Member Function Documentation

◆ add_task_parallel_work()

template<class TMemInterface >
bool task_scheduler::base_task< TMemInterface >::add_task_parallel_work ( function_type  _work_function)

Adds the task parallel work.

Parameters
_work_functionThe work function.
Returns
bool.

◆ after_run()

template<class TMemInterface >
void task_scheduler::base_task< TMemInterface >::after_run ( )
protectedvirtual

Callback is called after a task is run

Implements task_scheduler::base_task_events.

Reimplemented in task_scheduler::base_data_task< TMemInterface, TDataType >.

◆ before_scheduled()

template<class TMemInterface >
void task_scheduler::base_task< TMemInterface >::before_scheduled ( thread_num_t  _scheduled_on_num_workers)
protectedvirtual

Callback is called when a task is scheduled

Implements task_scheduler::base_task_events.

Reimplemented in task_scheduler::base_data_task< TMemInterface, TDataType >.

◆ get_recommended_num_workers()

template<class TMemInterface >
thread_num_t task_scheduler::base_task< TMemInterface >::get_recommended_num_workers ( )
virtual

Gets the best number of workers for the task every frame

Parameters
_num_workersThe number workers.

Reimplemented in task_scheduler::base_data_task< TMemInterface, TDataType >.

◆ kick_dependent_tasks()

template<class TMemInterface >
void task_scheduler::base_task< TMemInterface >::kick_dependent_tasks ( )

Kicks the dependent tasks.

◆ link_task()

template<class TMemInterface >
bool task_scheduler::base_task< TMemInterface >::link_task ( task_type _next_task)

Links the task.

Parameters
_next_taskThe next task.
Returns
bool.

◆ operator()()

template<class TMemInterface >
bool task_scheduler::base_task< TMemInterface >::operator() ( )

Operator()s this instance.

Returns
bool.

◆ run()

template<class TMemInterface >
virtual bool task_scheduler::base_task< TMemInterface >::run ( )
protectedpure virtual

Calls the working function internally

Returns
bool.

Implemented in task_scheduler::base_data_task< TMemInterface, TDataType >, and task_scheduler::base_worker_task< TMemInterface >.

◆ set_num_workers() [1/2]

template<class TMemInterface >
void task_scheduler::base_task< TMemInterface >::set_num_workers ( thread_num_t  _num_workers)

Sets the number workers.

Parameters
_num_workersThe number workers.

◆ set_num_workers() [2/2]

template<class TMemInterface >
void task_scheduler::base_task< TMemInterface >::set_num_workers ( percentage_t  _percentage_workers)

Sets the number workers.

Parameters
_percentage_workersThe percentage workers.

◆ set_thread_affinity()

template<class TMemInterface >
void task_scheduler::base_task< TMemInterface >::set_thread_affinity ( thread_mask_int_t  _mask)

Sets the thread affinity.

Parameters
_maskThe mask.

◆ set_thread_exclusion()

template<class TMemInterface >
void task_scheduler::base_task< TMemInterface >::set_thread_exclusion ( thread_mask_int_t  _mask)

Sets the thread exclusion.

Parameters
_maskThe mask.

Member Data Documentation

◆ add_task_parallel_work_detector

template<class TMemInterface >
thread_unsafe_access_storage task_scheduler::base_task< TMemInterface >::add_task_parallel_work_detector

The add task parallel work detector

◆ debug

template<class TMemInterface >
debug_container task_scheduler::base_task< TMemInterface >::debug

The debug

◆ persistent

template<class TMemInterface >
persistent_container task_scheduler::base_task< TMemInterface >::persistent

The persistent

◆ task_graph

template<class TMemInterface >
task_graph_type& task_scheduler::base_task< TMemInterface >::task_graph

The task graph

◆ transient

template<class TMemInterface >
transient_container task_scheduler::base_task< TMemInterface >::transient

The transient


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