Mantid
|
The ThreadScheduler object defines how tasks are allocated to threads and in what order. More...
#include <ThreadScheduler.h>
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< Task > | pop (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... | |
The ThreadScheduler object defines how tasks are allocated to threads and in what order.
It holds the queue of tasks.
Definition at line 32 of file ThreadScheduler.h.
|
inline |
Constructor.
Definition at line 36 of file ThreadScheduler.h.
|
virtualdefault |
Destructor.
|
inlinevirtual |
Signal to the scheduler that a task is complete.
The scheduler may release mutexes, etc.
exception | :: the exception that aborted the run. |
Definition at line 71 of file ThreadScheduler.h.
Referenced by Mantid::Kernel::ThreadPoolRunnable::run().
|
pure virtual |
Empty out the queue.
Implemented in Mantid::Kernel::ThreadSchedulerFIFO, Mantid::Kernel::ThreadSchedulerLargestCost, and Mantid::Kernel::ThreadSchedulerMutexes.
|
pure virtual |
Returns true if the queue is empty.
Implemented in Mantid::Kernel::ThreadSchedulerFIFO, Mantid::Kernel::ThreadSchedulerLargestCost, and Mantid::Kernel::ThreadSchedulerMutexes.
Referenced by Mantid::Kernel::ThreadPoolRunnable::run().
|
inlinevirtual |
Signal to the scheduler that a task is complete.
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().
|
inline |
Returns true if the execution was aborted.
Definition at line 102 of file ThreadScheduler.h.
|
inline |
Returns the exception that was caught, if any.
Definition at line 99 of file ThreadScheduler.h.
|
pure virtual |
Retrieves the next Task to execute.
threadnum | :: ID of the calling thread. |
Implemented in Mantid::Kernel::ThreadSchedulerFIFO, Mantid::Kernel::ThreadSchedulerLIFO, Mantid::Kernel::ThreadSchedulerLargestCost, and Mantid::Kernel::ThreadSchedulerMutexes.
Referenced by Mantid::Kernel::ThreadPoolRunnable::run().
|
pure virtual |
Add a Task to the queue.
newTask | :: Task to add to queue |
Implemented in Mantid::Kernel::ThreadSchedulerFIFO, Mantid::Kernel::ThreadSchedulerLargestCost, and Mantid::Kernel::ThreadSchedulerMutexes.
Referenced by Mantid::DataHandling::LoadBankFromDiskTask::run().
|
pure virtual |
Returns the size of the queue.
Implemented in Mantid::Kernel::ThreadSchedulerFIFO, Mantid::Kernel::ThreadSchedulerLargestCost, and Mantid::Kernel::ThreadSchedulerMutexes.
Referenced by Mantid::MDAlgorithms::MinusMD::doMinus(), Mantid::MDAlgorithms::PlusMD::doPlus(), and Mantid::MDAlgorithms::ConvertToDiffractionMDWorkspace::exec().
|
inline |
Returns the total cost of all Task's in the queue.
Definition at line 91 of file ThreadScheduler.h.
|
inline |
Returns the total cost of all Task's in the queue.
Definition at line 95 of file ThreadScheduler.h.
|
protected |
The run was aborted due to an exception.
Definition at line 114 of file ThreadScheduler.h.
|
protected |
The exception that aborted the run.
Definition at line 112 of file ThreadScheduler.h.
|
protected |
Total cost of all tasks.
Definition at line 106 of file ThreadScheduler.h.
|
protected |
Accumulated cost of tasks that have been executed (popped)
Definition at line 108 of file ThreadScheduler.h.
|
protected |
Mutex to prevent simultaneous access to the queue.
Definition at line 110 of file ThreadScheduler.h.