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

A First-In-First-Out Thread Scheduler. More...

#include <ThreadScheduler.h>

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

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.
 
 ThreadSchedulerFIFO ()
 
 ~ThreadSchedulerFIFO () 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::deque< std::shared_ptr< Task > > m_queue
 Queue of tasks.
 
- 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.
 

Detailed Description

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 143 of file ThreadScheduler.h.

Constructor & Destructor Documentation

◆ ThreadSchedulerFIFO()

Mantid::Kernel::ThreadSchedulerFIFO::ThreadSchedulerFIFO ( )
inline

Definition at line 145 of file ThreadScheduler.h.

◆ ~ThreadSchedulerFIFO()

Mantid::Kernel::ThreadSchedulerFIFO::~ThreadSchedulerFIFO ( )
inlineoverride

Destructor.

Definition at line 148 of file ThreadScheduler.h.

Member Function Documentation

◆ clear()

void Mantid::Kernel::ThreadSchedulerFIFO::clear ( )
inlinefinaloverridevirtual

Empty out the queue.

Implements Mantid::Kernel::ThreadScheduler.

Definition at line 191 of file ThreadScheduler.h.

◆ empty()

bool Mantid::Kernel::ThreadSchedulerFIFO::empty ( )
inlineoverridevirtual
Returns
true if the queue is empty

Implements Mantid::Kernel::ThreadScheduler.

Definition at line 152 of file ThreadScheduler.h.

◆ pop()

std::shared_ptr< Task > Mantid::Kernel::ThreadSchedulerFIFO::pop ( size_t  threadnum)
inlineoverridevirtual

Retrieves the next Task to execute.

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

Implements Mantid::Kernel::ThreadScheduler.

Reimplemented in Mantid::Kernel::ThreadSchedulerLIFO.

Definition at line 167 of file ThreadScheduler.h.

References UNUSED_ARG.

◆ push()

void Mantid::Kernel::ThreadSchedulerFIFO::push ( std::shared_ptr< Task >  newTask)
inlineoverridevirtual

Add a Task to the queue.

Parameters
newTask:: Task to add to queue

Implements Mantid::Kernel::ThreadScheduler.

Definition at line 158 of file ThreadScheduler.h.

◆ size()

size_t Mantid::Kernel::ThreadSchedulerFIFO::size ( )
inlineoverridevirtual

Member Data Documentation

◆ m_queue

std::deque<std::shared_ptr<Task> > Mantid::Kernel::ThreadSchedulerFIFO::m_queue
protected

Queue of tasks.

Definition at line 202 of file ThreadScheduler.h.


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