Beatmup
Beatmup::TaskThread Class Referenceabstract

Thread executing tasks. More...

#include <parallelism.h>

Inheritance diagram for Beatmup::TaskThread:
Beatmup::ThreadPool::TaskThreadImpl

Public Member Functions

ThreadIndex currentThread () const
 
bool isManaging () const
 
virtual ThreadIndex numThreads () const =0
 
virtual bool isTaskAborted () const =0
 Returns true if the task is asked to stop from outside. More...
 
virtual void synchronize ()=0
 Blocks until all the other threads running the same task reach the same point. More...
 

Protected Member Functions

 TaskThread (ThreadIndex index)
 

Protected Attributes

ThreadIndex index
 current thread index More...
 

Private Member Functions

 TaskThread (const TaskThread &)=delete
 

Detailed Description

Thread executing tasks.

Definition at line 154 of file parallelism.h.

Constructor & Destructor Documentation

◆ TaskThread() [1/2]

Beatmup::TaskThread::TaskThread ( const TaskThread )
privatedelete

◆ TaskThread() [2/2]

Beatmup::TaskThread::TaskThread ( ThreadIndex  index)
inlineprotected

Definition at line 159 of file parallelism.h.

159 : index(index) {}
ThreadIndex index
current thread index
Definition: parallelism.h:157

Member Function Documentation

◆ currentThread()

ThreadIndex Beatmup::TaskThread::currentThread ( ) const
inline
Returns
number of this thread.

Definition at line 165 of file parallelism.h.

165  {
166  return index;
167  }

◆ isManaging()

bool Beatmup::TaskThread::isManaging ( ) const
inline
Returns
true if this thread is the managing thread

Definition at line 172 of file parallelism.h.

172  {
173  return index == 0;
174  }

◆ numThreads()

virtual ThreadIndex Beatmup::TaskThread::numThreads ( ) const
pure virtual
Returns
overall number of threads working on the current task.

Implemented in Beatmup::ThreadPool::TaskThreadImpl.

◆ isTaskAborted()

virtual bool Beatmup::TaskThread::isTaskAborted ( ) const
pure virtual

Returns true if the task is asked to stop from outside.

Implemented in Beatmup::ThreadPool::TaskThreadImpl.

◆ synchronize()

virtual void Beatmup::TaskThread::synchronize ( )
pure virtual

Blocks until all the other threads running the same task reach the same point.

"The same point" is the same number of calls to synchronize(). This function does not throw any exception to be caught in the task code. However, if a thread running the task has failed, this function throws an exception the thread pool takes care of. This ensures a valid thread pool state and avoids dead locks when a task fails to proceed.

Implemented in Beatmup::ThreadPool::TaskThreadImpl.

Member Data Documentation

◆ index

ThreadIndex Beatmup::TaskThread::index
protected

current thread index

Definition at line 157 of file parallelism.h.


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