Mantid
|
A FunctionTask can easily create a Task from a method pointer. More...
#include <FunctionTask.h>
Public Types | |
using | voidFunction = void(*)() |
Typedef for a function with no arguments and no return. More... | |
Public Member Functions | |
FunctionTask (std::function< void()> func, double cost=1.0) | |
Constructor for a simple boost bound function. More... | |
FunctionTask (voidFunction func, double cost=1.0) | |
Constructor for a simple void function. More... | |
void | run () override |
Main method that performs the work for the task. More... | |
Public Member Functions inherited from Mantid::Kernel::Task | |
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 | |
std::function< void()> | m_voidFunc |
Protected Attributes inherited from Mantid::Kernel::Task | |
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... | |
A FunctionTask can easily create a Task from a method pointer.
The FunctionTask will simply run the provided method.
Definition at line 31 of file FunctionTask.h.
using Mantid::Kernel::FunctionTask::voidFunction = void (*)() |
Typedef for a function with no arguments and no return.
Definition at line 34 of file FunctionTask.h.
|
inline |
Constructor for a simple void function.
Pro-tip: use std::bind(f, argument1, argument2) (for example) to turn a function that takes an argument into a argument-less function pointer.
Use std::bind(&ClassName::function, &*this, arg1, arg2) to bind to a class method of this.
func | :: pointer to a void function() |
cost | :: computational cost |
Definition at line 48 of file FunctionTask.h.
|
inline |
Constructor for a simple boost bound function.
Pro-tip: use std::bind(f, argument1, argument2) (for example) to turn a function that takes an argument into a argument-less function pointer.
Use std::bind(&ClassName::function, &*this, arg1, arg2) to bind to a class method of this.
func | :: std::function<> returned by std::bind() |
cost | :: computational cost |
Definition at line 63 of file FunctionTask.h.
|
inlineoverridevirtual |
Main method that performs the work for the task.
Implements Mantid::Kernel::Task.
Definition at line 67 of file FunctionTask.h.
|
protected |
Definition at line 75 of file FunctionTask.h.