|
Mantid
|
A Largest Cost Thread Scheduler. More...
#include <ThreadScheduler.h>
Public Member Functions | |
| void | clear () override final |
| Empty out the queue. | |
| bool | empty () override |
| std::shared_ptr< Task > | pop (size_t threadnum) override |
| Retrieves the next Task to execute. | |
| void | push (std::shared_ptr< Task > newTask) override |
| Add a Task to the queue. | |
| size_t | size () override |
| Returns the size of the queue. | |
| ThreadSchedulerLargestCost () | |
| ~ThreadSchedulerLargestCost () override | |
| Destructor. | |
Public Member Functions inherited from Mantid::Kernel::ThreadScheduler | |
| virtual void | abort (std::runtime_error exception) |
| Signal to the scheduler that a task is complete. | |
| virtual void | finished (Task *task, size_t threadnum) |
| Signal to the scheduler that a task is complete. | |
| bool | getAborted () |
| Returns true if the execution was aborted. | |
| std::runtime_error | getAbortException () |
| Returns the exception that was caught, if any. | |
| bool | hasBusyThreads () const |
| Returns true if any thread is busy. | |
| void | markBusy () |
| Mark a thread as busy. | |
| void | markIdle () |
| Mark a thread as no longer busy. See markBusy(). | |
| ThreadScheduler () | |
| Constructor. | |
| double | totalCost () |
| Returns the total cost of all Task's in the queue. | |
| double | totalCostExecuted () |
| Returns the total cost of all Task's in the queue. | |
| virtual | ~ThreadScheduler ()=default |
| Destructor. | |
Protected Attributes | |
| std::multimap< double, std::shared_ptr< Task > > | m_map |
| A multimap keeps tasks sorted by the key (cost) | |
Protected Attributes inherited from Mantid::Kernel::ThreadScheduler | |
| bool | m_aborted |
| The run was aborted due to an exception. | |
| std::runtime_error | m_abortException |
| The exception that aborted the run. | |
| double | m_cost |
| Total cost of all tasks. | |
| double | m_costExecuted |
| Accumulated cost of tasks that have been executed (popped) | |
| std::atomic< size_t > | m_numBusyThreads {0} |
| Number of threads that are getting or running a task. | |
| std::mutex | m_queueLock |
| Mutex to prevent simultaneous access to the queue. | |
A Largest Cost Thread Scheduler.
The scheduled tasks are run so that the most time-consuming (highest cost) taks are run first. This tends to optimize task allocation the best. http://en.wikipedia.org/wiki/Bin_packing_problem
Interally, it uses a multimap to keep elements sorted while inserting them.
Definition at line 245 of file ThreadScheduler.h.
|
inline |
Definition at line 247 of file ThreadScheduler.h.
|
inlineoverride |
Destructor.
Definition at line 250 of file ThreadScheduler.h.
|
inlinefinaloverridevirtual |
Empty out the queue.
Implements Mantid::Kernel::ThreadScheduler.
Definition at line 295 of file ThreadScheduler.h.
|
inlineoverridevirtual |
Implements Mantid::Kernel::ThreadScheduler.
Definition at line 254 of file ThreadScheduler.h.
|
inlineoverridevirtual |
Retrieves the next Task to execute.
| threadnum | :: ID of the calling thread. |
Implements Mantid::Kernel::ThreadScheduler.
Definition at line 269 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 260 of file ThreadScheduler.h.
|
inlineoverridevirtual |
Returns the size of the queue.
Implements Mantid::Kernel::ThreadScheduler.
Definition at line 287 of file ThreadScheduler.h.
|
protected |
A multimap keeps tasks sorted by the key (cost)
Definition at line 306 of file ThreadScheduler.h.