Reference documentation for deal.II version 9.0.0
|
#include <deal.II/base/thread_management.h>
Public Member Functions | |
Task (const std::function< RT()> &function_object) | |
Task (const Task< RT > &t) | |
Task ()=default | |
void | join () const |
bool | joinable () const |
internal::return_value< RT >::reference_type | return_value () |
bool | operator== (const Task &t) const |
Static Public Member Functions | |
static ::ExceptionBase & | ExcNoTask () |
Private Attributes | |
std::shared_ptr< internal::TaskDescriptor< RT > > | task_descriptor |
Describes one task object based on the Threading Building Blocks' Task. Note that the call to join() must be executed on the same thread as the call to the constructor. Otherwise, there might be a deadlock. In other words, a Task object should never passed on to another task for calling the join() method.
Definition at line 1347 of file thread_management.h.
|
inline |
Construct a task object given a function object to execute on the task, and then schedule this function for execution.
Definition at line 1675 of file thread_management.h.
|
inline |
Copy constructor.
Definition at line 1690 of file thread_management.h.
|
default |
Default constructor. You can't do much with a task object constructed this way, except for assigning it a task object that holds data created by the Threads::new_task() functions.
|
inline |
Join the task represented by this object, i.e. wait for it to finish.
A task can be joined multiple times (while the first join() operation may block until the task has completed running, all successive attempts to join will return immediately).
Definition at line 1717 of file thread_management.h.
|
inline |
Return whether the current object can be joined. You can join a task object once a task (typically created with Threads::new_task()) has actually been assigned to it. On the other hand, the function returns false if the object has been default constructed.
A task can be joined multiple times (while the first join() operation may block until the task has completed running, all successive attempts to join will return immediately). Consequently, if this function returns true, it will continue to return true until the task object it reports on is assigned to from another object.
Definition at line 1735 of file thread_management.h.
|
inline |
Get the return value of the function of the task. Since it is only available once the thread finishes, this function internally also calls join(). You can call this function multiple times as long as the object refers to the same task, and expect to get the same return value every time. (With the exception of the case where the returned object has been moved; see below.)
const
reference to the returned object, instead of the returned object. This allows writing code such as const
) reference to support code such as this: std::move
the returned object (namely, the std::unique_ptr
object) because std::unique_ptr
objects can not be copied. In other words, to get the pointer out of the object returned from the task, it needs to be moved, and in order to be moved, the current function needs to return a writable (non-const
) reference.Definition at line 1786 of file thread_management.h.
|
inline |
Check for equality of task objects. Since objects of this class store an implicit pointer to an object that exists exactly once for each task, the check is simply to compare these pointers.
Definition at line 1798 of file thread_management.h.
|
private |
Shared pointer to the object representing the task. This makes sure that the object lives as long as there is at least one subscriber to it.
Definition at line 1822 of file thread_management.h.