Reference documentation for deal.II version 8.5.1
|
#include <deal.II/base/thread_management.h>
Public Member Functions | |
Thread (const std_cxx11::function< RT()> &function) | |
Thread () | |
Thread (const Thread< RT > &t) | |
void | join () const |
RT | return_value () |
bool | valid () const |
bool | operator== (const Thread &t) const |
Private Attributes | |
std_cxx11::shared_ptr< internal::ThreadDescriptor< RT > > | thread_descriptor |
An object that represents a spawned thread. This object can be freely copied around in user space, and all instances will represent the same thread and can require to wait for its termination and access its return value.
Threads can be abandoned, i.e. if you just call Threads::new_thread but don't care about the returned object, or if you assign the return Threads::Thread object to an object that subsequently goes out of scope, then the thread previously created will still continue to do work. You will simply not be able to access its return value any more, and it may also happen that your program terminates before the thread has finished its work.
The default value of the template argument is void
, so if the function you are calling on a new thread has no return value, you can omit the template argument.
Definition at line 1209 of file thread_management.h.
|
inline |
Construct a thread object with a function object.
Definition at line 1215 of file thread_management.h.
|
inline |
Default constructor. You can't do much with a thread object constructed this way, except for assigning it a thread object that holds data created by the new_thread() functions.
Definition at line 1228 of file thread_management.h.
|
inline |
Copy constructor.
Definition at line 1233 of file thread_management.h.
|
inline |
Join the thread represented by this object, i.e. wait for it to finish. If you have used the default constructor of this class and have not assigned a thread object to it, then this function is a no-op.
Definition at line 1243 of file thread_management.h.
|
inline |
Get the return value of the function of the thread. Since this is only available once the thread finishes, this implicitly also calls join().
Definition at line 1253 of file thread_management.h.
|
inline |
Return true if this object has had a thread associated with it, either by using the non-default constructor or by assignment.
Definition at line 1263 of file thread_management.h.
|
inline |
Check for equality of thread objects. Since objects of this class store an implicit pointer to an object that exists exactly once for each thread, the check is simply to compare these pointers.
Definition at line 1274 of file thread_management.h.
|
private |
Shared pointer to the object representing the thread, and abstracting operating system functions to work on it. Boost's shared pointer implementation will make sure that that object lives as long as there is at least one subscriber to it.
Definition at line 1286 of file thread_management.h.