Reference documentation for deal.II version 9.2.0
|
#include <deal.II/base/thread_management.h>
Public Member Functions | |
Task (const std::function< RT()> &function_object) | |
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 1191 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 1490 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 1525 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 1544 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 1595 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 1608 of file thread_management.h.