deal.II version GIT relicensing-2289-g1e5549a87a 2024-12-21 21:30:00+00:00
|
Public Member Functions | |
TaskData (std::future< RT > &&future) noexcept | |
TaskData (const TaskData &)=delete | |
TaskData (TaskData &&)=delete | |
TaskData & | operator= (const TaskData &)=delete |
TaskData & | operator= (TaskData &&)=delete |
~TaskData () noexcept | |
void | wait () |
internal::return_value< RT >::reference_type | get () |
Private Attributes | |
std::mutex | mutex |
std::future< RT > | future |
std::atomic< bool > | task_has_finished |
internal::return_value< RT > | returned_object |
std::unique_ptr< tbb::task_group > | task_group |
Friends | |
class | Task< RT > |
A data structure that holds a std::future into which the task deposits its return value. Since one can only call std::future::get() once, we do so in the get() member function and then move the returned object into the returned_object
member variable from where we can read it multiple times and from where it can also be moved away if it is not copyable.
Definition at line 848 of file thread_management.h.
|
inlinenoexcept |
Constructor. Initializes an std::future object and assumes that the task so set has not finished yet.
Definition at line 855 of file thread_management.h.
|
delete |
There can only be one TaskData object referencing a task. Make sure that these objects are not copied.
|
delete |
There can only be one TaskData object referencing a task. Make sure that these objects are not moved.
|
inlinenoexcept |
Destructor. Wait for the results to be ready. This ensures that the last Task object holding a shared pointer to the current TaskData object blocks until the task has actually finished – in essence, this makes sure that one cannot just abandon a task completely by letting all Task objects that point to it go out of scope.
Definition at line 896 of file thread_management.h.
|
delete |
There can only be one TaskData object referencing a task. Make sure that these objects are not copied.
|
delete |
There can only be one TaskData object referencing a task. Make sure that these objects are not moved.
|
inline |
Wait for the std::future object to be ready, i.e., for the time when the std::promise receives its value. If this has already happened, this function can follow a fast path.
Definition at line 935 of file thread_management.h.
|
inline |
Definition at line 1064 of file thread_management.h.
|
friend |
Definition at line 1117 of file thread_management.h.
|
private |
A mutex used to synchronize access to the data structures of this class.
Definition at line 1075 of file thread_management.h.
|
private |
The promise associated with the task that is represented by the current class.
Definition at line 1081 of file thread_management.h.
|
private |
A boolean indicating whether the task in question has finished.
std::atomic_bool
here because we have to make sure that concurrent reads and stores between threads are properly synchronized, and that sequential reads on a given thread are not reordered or optimized away. A std::atomic [1] achieves this because (if not otherwise annotated) reads and stores to the boolean are subject to the std::memory_order_seq_cst memory ordering [2]. This ensures that Schmidt's double checking does indeed work. For additional information (and a potentially more efficient implementation) see [3].[1] https://en.cppreference.com/w/cpp/atomic/atomic [2] https://en.cppreference.com/w/cpp/atomic/memory_order [3] https://preshing.com/20130930/double-checked-locking-is-fixed-in-cpp11/
Definition at line 1101 of file thread_management.h.
|
private |
The place where the returned value is moved to once the std::future has delivered.
Definition at line 1107 of file thread_management.h.
|
private |
A task group object we can wait for. This object is created in the constructor, and is removed as soon as we have determined that the task has finished, so as to free any resources the TBB may still be holding in order to allow programs to still check on the status of a task in this group.
Definition at line 1117 of file thread_management.h.