Mantid
|
A First-In-First-Out Thread Scheduler. More...
#include <ThreadScheduler.h>
Public Member Functions | |
void | clear () override |
Empty out the queue. More... | |
bool | empty () override |
std::shared_ptr< Task > | pop (size_t threadnum) override |
Retrieves the next Task to execute. More... | |
void | push (std::shared_ptr< Task > newTask) override |
Add a Task to the queue. More... | |
size_t | size () override |
Returns the size of the queue. More... | |
ThreadSchedulerFIFO () | |
~ThreadSchedulerFIFO () override | |
Destructor. More... | |
Public Member Functions inherited from Mantid::Kernel::ThreadScheduler | |
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 | |
std::deque< std::shared_ptr< Task > > | m_queue |
Queue of tasks. More... | |
Protected Attributes inherited from Mantid::Kernel::ThreadScheduler | |
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... | |
A First-In-First-Out Thread Scheduler.
A queue of tasks is maintained and are run in the order they were submitted.
Definition at line 126 of file ThreadScheduler.h.
|
inline |
Definition at line 128 of file ThreadScheduler.h.
|
inlineoverride |
Destructor.
Definition at line 131 of file ThreadScheduler.h.
|
inlineoverridevirtual |
Empty out the queue.
Implements Mantid::Kernel::ThreadScheduler.
Definition at line 174 of file ThreadScheduler.h.
|
inlineoverridevirtual |
Implements Mantid::Kernel::ThreadScheduler.
Definition at line 135 of file ThreadScheduler.h.
|
inlineoverridevirtual |
Retrieves the next Task to execute.
threadnum | :: ID of the calling thread. |
Implements Mantid::Kernel::ThreadScheduler.
Reimplemented in Mantid::Kernel::ThreadSchedulerLIFO.
Definition at line 150 of file ThreadScheduler.h.
References UNUSED_ARG.
|
inlineoverridevirtual |
Add a Task to the queue.
newTask | :: Task to add to queue |
Implements Mantid::Kernel::ThreadScheduler.
Definition at line 141 of file ThreadScheduler.h.
|
inlineoverridevirtual |
Returns the size of the queue.
Implements Mantid::Kernel::ThreadScheduler.
Definition at line 166 of file ThreadScheduler.h.
Referenced by Mantid::MDAlgorithms::ConvToMDEventsWS::appendEventsFromInputWS(), and Mantid::MDAlgorithms::ConvToMDHistoWS::runConversion().
|
protected |
Queue of tasks.
Definition at line 185 of file ThreadScheduler.h.