Nazara Engine  0.4
A fast, complete, cross-platform API designed for game development
Nz::TaskScheduler Class Reference

Core class that represents a thread pool. More...

Static Public Member Functions

template<typename F >
static void AddTask (F function)
 Adds a task to the pending list. More...
 
template<typename F , typename... Args>
static void AddTask (F function, Args &&... args)
 Adds a task to the pending list. More...
 
template<typename C >
static void AddTask (void(C::*function)(), C *object)
 Adds a task to the pending list. More...
 
static unsigned int GetWorkerCount ()
 Gets the number of threads. More...
 
static bool Initialize ()
 Initializes the TaskScheduler class. More...
 
static void Run ()
 Runs the pending works. More...
 
static void SetWorkerCount (unsigned int workerCount)
 Sets the number of workers. More...
 
static void Uninitialize ()
 Uninitializes the TaskScheduler class.
 
static void WaitForTasks ()
 Waits for tasks to be done. More...
 

Detailed Description

Core class that represents a thread pool.

Core class that represents a pool of threads.

Remarks
Initialized should be called first

Member Function Documentation

◆ AddTask() [1/3]

template<typename F >
void Nz::TaskScheduler::AddTask ( function)
static

Adds a task to the pending list.

Parameters
functionTask that the pool will execute

◆ AddTask() [2/3]

template<typename F , typename... Args>
void Nz::TaskScheduler::AddTask ( function,
Args &&...  args 
)
static

Adds a task to the pending list.

Parameters
functionTask that the pool will execute
argsArguments of the function

◆ AddTask() [3/3]

template<typename C >
void Nz::TaskScheduler::AddTask ( void(C::*)()  function,
C *  object 
)
static

Adds a task to the pending list.

Parameters
functionTask that the pool will execute
objectObject on which the method will be called

◆ GetWorkerCount()

unsigned int Nz::TaskScheduler::GetWorkerCount ( )
static

Gets the number of threads.

Returns
Number of threads, if none, the number of simulatenous threads on the processor is returned

◆ Initialize()

bool Nz::TaskScheduler::Initialize ( )
static

Initializes the TaskScheduler class.

Returns
true if everything is ok

◆ Run()

void Nz::TaskScheduler::Run ( )
static

Runs the pending works.

Remarks
Produce a NazaraError if the class is not initialized

◆ SetWorkerCount()

void Nz::TaskScheduler::SetWorkerCount ( unsigned int  workerCount)
static

Sets the number of workers.

Parameters
workerCountNumber of simulatnous threads handling the tasks
Remarks
Produce a NazaraError if the class is not initialized and NAZARA_CORE_SAFE is defined

◆ WaitForTasks()

void Nz::TaskScheduler::WaitForTasks ( )
static

Waits for tasks to be done.

Remarks
Produce a NazaraError if the class is not initialized

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