Mantid
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
Mantid::Kernel::ThreadScheduler Class Referenceabstract

The ThreadScheduler object defines how tasks are allocated to threads and in what order. More...

#include <ThreadScheduler.h>

Inheritance diagram for Mantid::Kernel::ThreadScheduler:
Mantid::Kernel::ThreadSchedulerFIFO Mantid::Kernel::ThreadSchedulerLargestCost Mantid::Kernel::ThreadSchedulerMutexes Mantid::Kernel::ThreadSchedulerLIFO

Public Member Functions

virtual void abort (std::runtime_error exception)
 Signal to the scheduler that a task is complete. More...
 
virtual void clear ()=0
 Empty out the queue. More...
 
virtual bool empty ()=0
 Returns true if the queue is empty. More...
 
virtual void finished (Task *task, size_t threadnum)
 Signal to the scheduler that a task is complete. More...
 
bool getAborted ()
 Returns true if the execution was aborted. More...
 
std::runtime_error getAbortException ()
 Returns the exception that was caught, if any. More...
 
virtual std::shared_ptr< Taskpop (size_t threadnum)=0
 Retrieves the next Task to execute. More...
 
virtual void push (std::shared_ptr< Task > newTask)=0
 Add a Task to the queue. More...
 
virtual size_t size ()=0
 Returns the size of the queue. More...
 
 ThreadScheduler ()
 Constructor. More...
 
double totalCost ()
 Returns the total cost of all Task's in the queue. More...
 
double totalCostExecuted ()
 Returns the total cost of all Task's in the queue. More...
 
virtual ~ThreadScheduler ()=default
 Destructor. More...
 

Protected Attributes

bool m_aborted
 The run was aborted due to an exception. More...
 
std::runtime_error m_abortException
 The exception that aborted the run. More...
 
double m_cost
 Total cost of all tasks. More...
 
double m_costExecuted
 Accumulated cost of tasks that have been executed (popped) More...
 
std::mutex m_queueLock
 Mutex to prevent simultaneous access to the queue. More...
 

Detailed Description

The ThreadScheduler object defines how tasks are allocated to threads and in what order.

It holds the queue of tasks.

Author
Janik Zikovsky, SNS
Date
Feb 7, 2011

Definition at line 32 of file ThreadScheduler.h.

Constructor & Destructor Documentation

◆ ThreadScheduler()

Mantid::Kernel::ThreadScheduler::ThreadScheduler ( )
inline

Constructor.

Definition at line 36 of file ThreadScheduler.h.

◆ ~ThreadScheduler()

virtual Mantid::Kernel::ThreadScheduler::~ThreadScheduler ( )
virtualdefault

Destructor.

Member Function Documentation

◆ abort()

virtual void Mantid::Kernel::ThreadScheduler::abort ( std::runtime_error  exception)
inlinevirtual

Signal to the scheduler that a task is complete.

The scheduler may release mutexes, etc.

Parameters
exception:: the exception that aborted the run.

Definition at line 71 of file ThreadScheduler.h.

Referenced by Mantid::Kernel::ThreadPoolRunnable::run().

◆ clear()

virtual void Mantid::Kernel::ThreadScheduler::clear ( )
pure virtual

◆ empty()

virtual bool Mantid::Kernel::ThreadScheduler::empty ( )
pure virtual

◆ finished()

virtual void Mantid::Kernel::ThreadScheduler::finished ( Task task,
size_t  threadnum 
)
inlinevirtual

Signal to the scheduler that a task is complete.

Parameters
task:: the Task that was completed.
threadnum:: Thread ID that launched the task

Reimplemented in Mantid::Kernel::ThreadSchedulerMutexes.

Definition at line 60 of file ThreadScheduler.h.

References UNUSED_ARG.

Referenced by Mantid::Kernel::ThreadPoolRunnable::run().

◆ getAborted()

bool Mantid::Kernel::ThreadScheduler::getAborted ( )
inline

Returns true if the execution was aborted.

Definition at line 102 of file ThreadScheduler.h.

◆ getAbortException()

std::runtime_error Mantid::Kernel::ThreadScheduler::getAbortException ( )
inline

Returns the exception that was caught, if any.

Definition at line 99 of file ThreadScheduler.h.

◆ pop()

virtual std::shared_ptr< Task > Mantid::Kernel::ThreadScheduler::pop ( size_t  threadnum)
pure virtual

Retrieves the next Task to execute.

Parameters
threadnum:: ID of the calling thread.
Returns
a Task pointer to execute.

Implemented in Mantid::Kernel::ThreadSchedulerFIFO, Mantid::Kernel::ThreadSchedulerLIFO, Mantid::Kernel::ThreadSchedulerLargestCost, and Mantid::Kernel::ThreadSchedulerMutexes.

Referenced by Mantid::Kernel::ThreadPoolRunnable::run().

◆ push()

virtual void Mantid::Kernel::ThreadScheduler::push ( std::shared_ptr< Task newTask)
pure virtual

◆ size()

virtual size_t Mantid::Kernel::ThreadScheduler::size ( )
pure virtual

◆ totalCost()

double Mantid::Kernel::ThreadScheduler::totalCost ( )
inline

Returns the total cost of all Task's in the queue.

Definition at line 91 of file ThreadScheduler.h.

◆ totalCostExecuted()

double Mantid::Kernel::ThreadScheduler::totalCostExecuted ( )
inline

Returns the total cost of all Task's in the queue.

Definition at line 95 of file ThreadScheduler.h.

Member Data Documentation

◆ m_aborted

bool Mantid::Kernel::ThreadScheduler::m_aborted
protected

The run was aborted due to an exception.

Definition at line 114 of file ThreadScheduler.h.

◆ m_abortException

std::runtime_error Mantid::Kernel::ThreadScheduler::m_abortException
protected

The exception that aborted the run.

Definition at line 112 of file ThreadScheduler.h.

◆ m_cost

double Mantid::Kernel::ThreadScheduler::m_cost
protected

Total cost of all tasks.

Definition at line 106 of file ThreadScheduler.h.

◆ m_costExecuted

double Mantid::Kernel::ThreadScheduler::m_costExecuted
protected

Accumulated cost of tasks that have been executed (popped)

Definition at line 108 of file ThreadScheduler.h.

◆ m_queueLock

std::mutex Mantid::Kernel::ThreadScheduler::m_queueLock
protected

Mutex to prevent simultaneous access to the queue.

Definition at line 110 of file ThreadScheduler.h.


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