Reference documentation for deal.II version 8.1.0
Public Member Functions | Private Attributes | List of all members

#include <thread_management.h>

Public Member Functions

 Thread (const std_cxx1x::function< RT()> &function)
 
 Thread ()
 
 Thread (const Thread< RT > &t)
 
void join () const
 
RT return_value ()
 
bool valid () const
 
bool operator== (const Thread &t)
 

Private Attributes

std_cxx1x::shared_ptr< internal::ThreadDescriptor< RT > > thread_descriptor
 

Detailed Description

template<typename RT = void>
class Threads::Thread< RT >

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.

Author
Wolfgang Bangerth, 2003, 2009

Definition at line 1542 of file thread_management.h.

Constructor & Destructor Documentation

template<typename RT = void>
Threads::Thread< RT >::Thread ( const std_cxx1x::function< RT()> &  function)
inline

Construct a thread object with a function object.

Definition at line 1549 of file thread_management.h.

template<typename RT = void>
Threads::Thread< RT >::Thread ( )
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 1567 of file thread_management.h.

template<typename RT = void>
Threads::Thread< RT >::Thread ( const Thread< RT > &  t)
inline

Copy constructor.

Definition at line 1572 of file thread_management.h.

Member Function Documentation

template<typename RT = void>
void Threads::Thread< RT >::join ( ) const
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 1585 of file thread_management.h.

template<typename RT = void>
RT Threads::Thread< RT >::return_value ( )
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 1599 of file thread_management.h.

template<typename RT = void>
bool Threads::Thread< RT >::valid ( ) const
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 1612 of file thread_management.h.

template<typename RT = void>
bool Threads::Thread< RT >::operator== ( const Thread< RT > &  t)
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 1627 of file thread_management.h.

Member Data Documentation

template<typename RT = void>
std_cxx1x::shared_ptr<internal::ThreadDescriptor<RT> > Threads::Thread< RT >::thread_descriptor
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 1644 of file thread_management.h.


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