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

A Task is a unit of work to be scheduled and run by a ThreadPool. More...

#include <Task.h>

Inheritance diagram for Mantid::Kernel::Task:
Mantid::DataHandling::LoadBankFromDiskTask Mantid::DataHandling::ProcessBankData Mantid::Kernel::FunctionTask

Public Member Functions

virtual double cost ()
 What is the computational cost of this task? More...
 
std::shared_ptr< std::mutex > getMutex ()
 Get the mutex object for this Task. More...
 
virtual void run ()=0
 Main method that performs the work for the task. More...
 
void setMutex (const std::shared_ptr< std::mutex > &mutex)
 Set the mutex object for this Task. More...
 
void setMutexObject (void *object)
 Use an arbitrary pointer to lock (mutex) the execution of this task. More...
 
 Task ()
 Default constructor. More...
 
 Task (double cost)
 Constructor with cost. More...
 
virtual ~Task ()=default
 Destructor. More...
 

Protected Attributes

double m_cost
 Cached computational cost for the thread. More...
 
std::shared_ptr< std::mutex > m_mutex
 Mutex associated with this task (can be NULL) More...
 

Detailed Description

A Task is a unit of work to be scheduled and run by a ThreadPool.

This class is abstract and will be overridden. Its main method is the run() method, which does the work.

Author
Janik Zikovsky, SNS
Date
Feb 8, 2011

Definition at line 29 of file Task.h.

Constructor & Destructor Documentation

◆ Task() [1/2]

Mantid::Kernel::Task::Task ( )
inline

Default constructor.

Definition at line 33 of file Task.h.

◆ Task() [2/2]

Mantid::Kernel::Task::Task ( double  cost)
inline

Constructor with cost.

Parameters
cost:: computational cost

Definition at line 40 of file Task.h.

◆ ~Task()

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

Destructor.

Member Function Documentation

◆ cost()

virtual double Mantid::Kernel::Task::cost ( )
inlinevirtual

What is the computational cost of this task?

Returns
a double that scales with the computational time.

Definition at line 53 of file Task.h.

Referenced by Mantid::Kernel::compareTasks().

◆ getMutex()

std::shared_ptr< std::mutex > Mantid::Kernel::Task::getMutex ( )
inline

Get the mutex object for this Task.

Returns
Mutex pointer, or NULL

Definition at line 72 of file Task.h.

Referenced by Mantid::Kernel::ThreadSchedulerMutexes::finished().

◆ run()

virtual void Mantid::Kernel::Task::run ( )
pure virtual

Main method that performs the work for the task.

Implemented in Mantid::DataHandling::LoadBankFromDiskTask, Mantid::DataHandling::ProcessBankData, and Mantid::Kernel::FunctionTask.

◆ setMutex()

void Mantid::Kernel::Task::setMutex ( const std::shared_ptr< std::mutex > &  mutex)
inline

Set the mutex object for this Task.

Parameters
mutex:: Mutex pointer, or NULL

Definition at line 78 of file Task.h.

Referenced by Mantid::DataHandling::LoadBankFromDiskTask::LoadBankFromDiskTask().

◆ setMutexObject()

void Mantid::Kernel::Task::setMutexObject ( void *  object)
inline

Use an arbitrary pointer to lock (mutex) the execution of this task.

For example, you might point to a particular EventList in memory to signify that this task will operate on this object.

Parameters
object:: any pointer.

Definition at line 63 of file Task.h.

References UNUSED_ARG.

Member Data Documentation

◆ m_cost

double Mantid::Kernel::Task::m_cost
protected

Cached computational cost for the thread.

Definition at line 82 of file Task.h.

Referenced by Mantid::DataHandling::LoadBankFromDiskTask::LoadBankFromDiskTask(), and Mantid::DataHandling::ProcessBankData::ProcessBankData().

◆ m_mutex

std::shared_ptr<std::mutex> Mantid::Kernel::Task::m_mutex
protected

Mutex associated with this task (can be NULL)

Definition at line 85 of file Task.h.


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