Reference documentation for deal.II version GIT 770e57895c 2022-08-12 17:05:02+00:00

## Public Member Functions

TaskData (std::future< RT > &&future) noexcept

void wait ()

internal::return_value< RT >::reference_type get ()

## Private Attributes

std::mutex mutex

std::future< RT > future

internal::return_value< RT > returned_object

## Detailed Description

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 1265 of file thread_management.h.

## Constructor & Destructor Documentation

template<typename RT = void>
inlinenoexcept

Constructor. Initializes an std::future object and assumes that the task so set has not finished yet.

Definition at line 1272 of file thread_management.h.

template<typename RT = void>
delete

There can only be one TaskData object referencing a task. Make sure that these objects are not copied.

template<typename RT = void>
delete

There can only be one TaskData object referencing a task. Make sure that these objects are not moved.

template<typename RT = void>
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 1310 of file thread_management.h.

## ◆ operator=() [1/2]

template<typename RT = void>
delete

There can only be one TaskData object referencing a task. Make sure that these objects are not copied.

## ◆ operator=() [2/2]

template<typename RT = void>
delete

There can only be one TaskData object referencing a task. Make sure that these objects are not moved.

## ◆ wait()

template<typename RT = void>
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 1349 of file thread_management.h.

## ◆ get()

template<typename RT = void>
inline

Definition at line 1397 of file thread_management.h.

## Friends And Related Function Documentation

template<typename RT = void>
friend

Definition at line 1446 of file thread_management.h.

## ◆ mutex

template<typename RT = void>
private

A mutex used to synchronize access to the data structures of this class.

Definition at line 1408 of file thread_management.h.

## ◆ future

template<typename RT = void>
private

The promise associated with the task that is represented by the current class.

Definition at line 1414 of file thread_management.h.

template<typename RT = void>
private

A boolean indicating whether the task in question has finished.

Note
We are using a 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].

Definition at line 1434 of file thread_management.h.

## ◆ returned_object

template<typename RT = void>
private

The place where the returned value is moved to once the std::future has delivered.

Definition at line 1440 of file thread_management.h.

template<typename RT = void>
private

A task group object we can wait for.

Definition at line 1446 of file thread_management.h.

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