Namespaces | |
namespace | internal |
Classes | |
class | DummyThreadMutex |
class | DummyThreadCondition |
class | DummyBarrier |
class | Mutex |
class | ConditionVariable |
class | PosixThreadBarrier |
class | Thread |
class | ThreadGroup |
Typedefs | |
typedef Mutex | ThreadMutex |
typedef ConditionVariable | ThreadCondition |
typedef PosixThreadBarrier | Barrier |
Functions | |
unsigned int | n_existing_threads () |
unsigned int | this_thread_id () |
template<typename ForwardIterator > | |
std::vector< std::pair < ForwardIterator, ForwardIterator > > | split_range (const ForwardIterator &begin, const ForwardIterator &end, const unsigned int n_intervals) |
std::vector< std::pair < unsigned int, unsigned int > > | split_interval (const unsigned int begin, const unsigned int end, const unsigned int n_intervals) |
template<typename RT > | |
internal::fun_encapsulator< RT, std_cxx1x::tuple<>, 0 > | spawn (RT(*fun_ptr)()) |
template<typename RT , typename C > | |
internal::fun_encapsulator< RT, std_cxx1x::tuple<>, 0 > | spawn (C &c, RT(C::*fun_ptr)()) |
template<typename RT , typename C > | |
internal::fun_encapsulator< RT, std_cxx1x::tuple<>, 0 > | spawn (const C &c, RT(C::*fun_ptr)() const) |
template<typename RT , typename Arg1 > | |
internal::fun_encapsulator< RT, std_cxx1x::tuple< Arg1 >, 1 > | spawn (RT(*fun_ptr)(Arg1)) |
template<typename RT , typename C , typename Arg1 > | |
internal::fun_encapsulator< RT, std_cxx1x::tuple< Arg1 >, 1 > | spawn (C &c, RT(C::*fun_ptr)(Arg1)) |
template<typename RT , typename C , typename Arg1 > | |
internal::fun_encapsulator< RT, std_cxx1x::tuple< Arg1 >, 1 > | spawn (const C &c, RT(C::*fun_ptr)(Arg1) const) |
template<typename RT , typename Arg1 , typename Arg2 > | |
internal::fun_encapsulator< RT, std_cxx1x::tuple< Arg1, Arg2 >, 2 > | spawn (RT(*fun_ptr)(Arg1, Arg2)) |
template<typename RT , typename C , typename Arg1 , typename Arg2 > | |
internal::fun_encapsulator< RT, std_cxx1x::tuple< Arg1, Arg2 >, 2 > | spawn (C &c, RT(C::*fun_ptr)(Arg1, Arg2)) |
template<typename RT , typename C , typename Arg1 , typename Arg2 > | |
internal::fun_encapsulator< RT, std_cxx1x::tuple< Arg1, Arg2 >, 2 > | spawn (const C &c, RT(C::*fun_ptr)(Arg1, Arg2) const) |
template<typename RT , typename Arg1 , typename Arg2 , typename Arg3 > | |
internal::fun_encapsulator< RT, std_cxx1x::tuple< Arg1, Arg2, Arg3 >, 3 > | spawn (RT(*fun_ptr)(Arg1, Arg2, Arg3)) |
template<typename RT , typename C , typename Arg1 , typename Arg2 , typename Arg3 > | |
internal::fun_encapsulator< RT, std_cxx1x::tuple< Arg1, Arg2, Arg3 >, 3 > | spawn (C &c, RT(C::*fun_ptr)(Arg1, Arg2, Arg3)) |
template<typename RT , typename C , typename Arg1 , typename Arg2 , typename Arg3 > | |
internal::fun_encapsulator< RT, std_cxx1x::tuple< Arg1, Arg2, Arg3 >, 3 > | spawn (const C &c, RT(C::*fun_ptr)(Arg1, Arg2, Arg3) const) |
template<typename RT , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 > | |
internal::fun_encapsulator< RT, std_cxx1x::tuple< Arg1, Arg2, Arg3, Arg4 >, 4 > | spawn (RT(*fun_ptr)(Arg1, Arg2, Arg3, Arg4)) |
template<typename RT , typename C , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 > | |
internal::fun_encapsulator< RT, std_cxx1x::tuple< Arg1, Arg2, Arg3, Arg4 >, 4 > | spawn (C &c, RT(C::*fun_ptr)(Arg1, Arg2, Arg3, Arg4)) |
template<typename RT , typename C , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 > | |
internal::fun_encapsulator< RT, std_cxx1x::tuple< Arg1, Arg2, Arg3, Arg4 >, 4 > | spawn (const C &c, RT(C::*fun_ptr)(Arg1, Arg2, Arg3, Arg4) const) |
template<typename RT , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 , typename Arg5 > | |
internal::fun_encapsulator< RT, std_cxx1x::tuple< Arg1, Arg2, Arg3, Arg4, Arg5 >, 5 > | spawn (RT(*fun_ptr)(Arg1, Arg2, Arg3, Arg4, Arg5)) |
template<typename RT , typename C , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 , typename Arg5 > | |
internal::fun_encapsulator< RT, std_cxx1x::tuple< Arg1, Arg2, Arg3, Arg4, Arg5 >, 5 > | spawn (C &c, RT(C::*fun_ptr)(Arg1, Arg2, Arg3, Arg4, Arg5)) |
template<typename RT , typename C , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 , typename Arg5 > | |
internal::fun_encapsulator< RT, std_cxx1x::tuple< Arg1, Arg2, Arg3, Arg4, Arg5 >, 5 > | spawn (const C &c, RT(C::*fun_ptr)(Arg1, Arg2, Arg3, Arg4, Arg5) const) |
template<typename RT , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 , typename Arg5 , typename Arg6 > | |
internal::fun_encapsulator< RT, std_cxx1x::tuple< Arg1, Arg2, Arg3, Arg4, Arg5, Arg6 >, 6 > | spawn (RT(*fun_ptr)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6)) |
template<typename RT , typename C , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 , typename Arg5 , typename Arg6 > | |
internal::fun_encapsulator< RT, std_cxx1x::tuple< Arg1, Arg2, Arg3, Arg4, Arg5, Arg6 >, 6 > | spawn (C &c, RT(C::*fun_ptr)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6)) |
template<typename RT , typename C , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 , typename Arg5 , typename Arg6 > | |
internal::fun_encapsulator< RT, std_cxx1x::tuple< Arg1, Arg2, Arg3, Arg4, Arg5, Arg6 >, 6 > | spawn (const C &c, RT(C::*fun_ptr)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6) const) |
template<typename RT , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 , typename Arg5 , typename Arg6 , typename Arg7 > | |
internal::fun_encapsulator< RT, std_cxx1x::tuple< Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7 >, 7 > | spawn (RT(*fun_ptr)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7)) |
template<typename RT , typename C , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 , typename Arg5 , typename Arg6 , typename Arg7 > | |
internal::fun_encapsulator< RT, std_cxx1x::tuple< Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7 >, 7 > | spawn (C &c, RT(C::*fun_ptr)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7)) |
template<typename RT , typename C , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 , typename Arg5 , typename Arg6 , typename Arg7 > | |
internal::fun_encapsulator< RT, std_cxx1x::tuple< Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7 >, 7 > | spawn (const C &c, RT(C::*fun_ptr)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7) const) |
template<typename RT , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 , typename Arg5 , typename Arg6 , typename Arg7 , typename Arg8 > | |
internal::fun_encapsulator< RT, std_cxx1x::tuple< Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8 >, 8 > | spawn (RT(*fun_ptr)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8)) |
template<typename RT , typename C , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 , typename Arg5 , typename Arg6 , typename Arg7 , typename Arg8 > | |
internal::fun_encapsulator< RT, std_cxx1x::tuple< Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8 >, 8 > | spawn (C &c, RT(C::*fun_ptr)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8)) |
template<typename RT , typename C , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 , typename Arg5 , typename Arg6 , typename Arg7 , typename Arg8 > | |
internal::fun_encapsulator< RT, std_cxx1x::tuple< Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8 >, 8 > | spawn (const C &c, RT(C::*fun_ptr)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8) const) |
template<typename RT , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 , typename Arg5 , typename Arg6 , typename Arg7 , typename Arg8 , typename Arg9 > | |
internal::fun_encapsulator< RT, std_cxx1x::tuple< Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9 >, 9 > | spawn (RT(*fun_ptr)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9)) |
template<typename RT , typename C , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 , typename Arg5 , typename Arg6 , typename Arg7 , typename Arg8 , typename Arg9 > | |
internal::fun_encapsulator< RT, std_cxx1x::tuple< Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9 >, 9 > | spawn (C &c, RT(C::*fun_ptr)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9)) |
template<typename RT , typename C , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 , typename Arg5 , typename Arg6 , typename Arg7 , typename Arg8 , typename Arg9 > | |
internal::fun_encapsulator< RT, std_cxx1x::tuple< Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9 >, 9 > | spawn (const C &c, RT(C::*fun_ptr)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9) const) |
typedef Mutex Threads::ThreadMutex |
Provide a backward compatible name (we used ThreadMutex up to release 6.1, but since it is already in a namespace Threads this seems redundant).
Provide a backward compatible name (we used ThreadCondition up to release 6.1, but since it is already in a namespace Threads this seems redundant).
typedef PosixThreadBarrier Threads::Barrier |
If using POSIX functions, then alias the POSIX wrapper classes to the names we use throughout the library.
Return the number of presently existing threads. This function may be useful in a situation where a large number of threads are concurrently, and you want to decide whether creation of another thread is reasonable or whether running the respective operation sequentially is more useful since already many more threads than processors are running.
Note that the function returns the total number of threads, not those actually running. Some of the threads may be waiting for locks and mutexes, or may be sleeping until they are delivered with data to work on.
Upon program start, this number is one. It is increased each time a thread is created using the Threads::spawn or Threads::spawn_n() functions. It is decreased once a thread terminates by returning from the function that was spawned.
Note that this means that only threads created and terminated through the interfaces of this namespace are taken care of. If threads are created by directly calling the respective functions of the operating system (e.g. pthread_create
for the POSIX thread interface), or if they are killed (e.g. either through pthread_exit
from the spawned thread, or pthread_kill
from another thread), then these events are not registered and counted for the result of this function.
Return a number used as id of this thread. This number is generated using the system call getpid
, or, if it exists gettid
. The result of either is converted to an integer and returned by this function.
gettid
, so that part of the code is untested yet. std::vector<std::pair<ForwardIterator,ForwardIterator> > Threads::split_range | ( | const ForwardIterator & | begin, | |
const ForwardIterator & | end, | |||
const unsigned int | n_intervals | |||
) | [inline] |
Split the range [begin,end)
into n_intervals
subintervals of equal size. The last interval will be a little bit larger, if the number of elements in the whole range is not exactly divisible by n_intervals
. The type of the iterators has to fulfill the requirements of a forward iterator, i.e. operator++
must be available, and of course it must be assignable.
A list of subintervals is returned as a vector of pairs of iterators, where each pair denotes the range [begin[i],end[i])
.
std::vector<std::pair<unsigned int,unsigned int> > Threads::split_interval | ( | const unsigned int | begin, | |
const unsigned int | end, | |||
const unsigned int | n_intervals | |||
) |
Split the interval [begin,end)
into subintervals of (almost) equal size. This function works mostly as the one before, with the difference that instead of iterators, now values are taken that define the whole interval.
internal::fun_encapsulator<RT,std_cxx1x::tuple<>,0> Threads::spawn | ( | RT(*)() | fun_ptr | ) | [inline] |
Overload of the spawn function for non-member or static member functions with no arguments.
internal::fun_encapsulator<RT,std_cxx1x::tuple<>,0> Threads::spawn | ( | C & | c, | |
RT(C::*)() | fun_ptr | |||
) | [inline] |
Overload of the non-const spawn function for member functions with no arguments.
internal::fun_encapsulator<RT,std_cxx1x::tuple<>,0> Threads::spawn | ( | const C & | c, | |
RT(C::*)() const | fun_ptr | |||
) | [inline] |
Overload of the spawn function for const member functions with no arguments.
internal::fun_encapsulator<RT,std_cxx1x::tuple<Arg1>,1> Threads::spawn | ( | RT(*)(Arg1) | fun_ptr | ) | [inline] |
Overload of the spawn function for non-member or static member functions with 1 argument.
internal::fun_encapsulator<RT,std_cxx1x::tuple<Arg1>,1> Threads::spawn | ( | C & | c, | |
RT(C::*)(Arg1) | fun_ptr | |||
) | [inline] |
Overload of the non-const spawn function for member functions with 1 argument.
internal::fun_encapsulator<RT,std_cxx1x::tuple<Arg1>,1> Threads::spawn | ( | const C & | c, | |
RT(C::*)(Arg1) const | fun_ptr | |||
) | [inline] |
Overload of the spawn function for const member functions with 1 argument.
internal::fun_encapsulator<RT,std_cxx1x::tuple<Arg1, Arg2>,2> Threads::spawn | ( | RT(*)(Arg1, Arg2) | fun_ptr | ) | [inline] |
Overload of the spawn function for non-member or static member functions with 2 arguments.
internal::fun_encapsulator<RT,std_cxx1x::tuple<Arg1, Arg2>,2> Threads::spawn | ( | C & | c, | |
RT(C::*)(Arg1, Arg2) | fun_ptr | |||
) | [inline] |
Overload of the non-const spawn function for member functions with 2 arguments.
internal::fun_encapsulator<RT,std_cxx1x::tuple<Arg1, Arg2>,2> Threads::spawn | ( | const C & | c, | |
RT(C::*)(Arg1, Arg2) const | fun_ptr | |||
) | [inline] |
Overload of the spawn function for const member functions with 2 arguments.
internal::fun_encapsulator<RT,std_cxx1x::tuple<Arg1, Arg2, Arg3>,3> Threads::spawn | ( | RT(*)(Arg1, Arg2, Arg3) | fun_ptr | ) | [inline] |
Overload of the spawn function for non-member or static member functions with 3 arguments.
internal::fun_encapsulator<RT,std_cxx1x::tuple<Arg1, Arg2, Arg3>,3> Threads::spawn | ( | C & | c, | |
RT(C::*)(Arg1, Arg2, Arg3) | fun_ptr | |||
) | [inline] |
Overload of the non-const spawn function for member functions with 3 arguments.
internal::fun_encapsulator<RT,std_cxx1x::tuple<Arg1, Arg2, Arg3>,3> Threads::spawn | ( | const C & | c, | |
RT(C::*)(Arg1, Arg2, Arg3) const | fun_ptr | |||
) | [inline] |
Overload of the spawn function for const member functions with 3 arguments.
internal::fun_encapsulator<RT,std_cxx1x::tuple<Arg1, Arg2, Arg3, Arg4>,4> Threads::spawn | ( | RT(*)(Arg1, Arg2, Arg3, Arg4) | fun_ptr | ) | [inline] |
Overload of the spawn function for non-member or static member functions with 4 arguments.
internal::fun_encapsulator<RT,std_cxx1x::tuple<Arg1, Arg2, Arg3, Arg4>,4> Threads::spawn | ( | C & | c, | |
RT(C::*)(Arg1, Arg2, Arg3, Arg4) | fun_ptr | |||
) | [inline] |
Overload of the non-const spawn function for member functions with 4 arguments.
internal::fun_encapsulator<RT,std_cxx1x::tuple<Arg1, Arg2, Arg3, Arg4>,4> Threads::spawn | ( | const C & | c, | |
RT(C::*)(Arg1, Arg2, Arg3, Arg4) const | fun_ptr | |||
) | [inline] |
Overload of the spawn function for const member functions with 4 arguments.
internal::fun_encapsulator<RT,std_cxx1x::tuple<Arg1, Arg2, Arg3, Arg4, Arg5>,5> Threads::spawn | ( | RT(*)(Arg1, Arg2, Arg3, Arg4, Arg5) | fun_ptr | ) | [inline] |
Overload of the spawn function for non-member or static member functions with 5 arguments.
internal::fun_encapsulator<RT,std_cxx1x::tuple<Arg1, Arg2, Arg3, Arg4, Arg5>,5> Threads::spawn | ( | C & | c, | |
RT(C::*)(Arg1, Arg2, Arg3, Arg4, Arg5) | fun_ptr | |||
) | [inline] |
Overload of the non-const spawn function for member functions with 5 arguments.
internal::fun_encapsulator<RT,std_cxx1x::tuple<Arg1, Arg2, Arg3, Arg4, Arg5>,5> Threads::spawn | ( | const C & | c, | |
RT(C::*)(Arg1, Arg2, Arg3, Arg4, Arg5) const | fun_ptr | |||
) | [inline] |
Overload of the spawn function for const member functions with 5 arguments.
internal::fun_encapsulator<RT,std_cxx1x::tuple<Arg1, Arg2, Arg3, Arg4, Arg5, Arg6>,6> Threads::spawn | ( | RT(*)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6) | fun_ptr | ) | [inline] |
Overload of the spawn function for non-member or static member functions with 6 arguments.
internal::fun_encapsulator<RT,std_cxx1x::tuple<Arg1, Arg2, Arg3, Arg4, Arg5, Arg6>,6> Threads::spawn | ( | C & | c, | |
RT(C::*)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6) | fun_ptr | |||
) | [inline] |
Overload of the non-const spawn function for member functions with 6 arguments.
internal::fun_encapsulator<RT, std_cxx1x::tuple<Arg1, Arg2, Arg3, Arg4, Arg5, Arg6>,6> Threads::spawn | ( | const C & | c, | |
RT(C::*)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6) const | fun_ptr | |||
) | [inline] |
Overload of the spawn function for const member functions with 6 arguments.
internal::fun_encapsulator<RT,std_cxx1x::tuple<Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7>,7> Threads::spawn | ( | RT(*)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7) | fun_ptr | ) | [inline] |
Overload of the spawn function for non-member or static member functions with 7 arguments.
internal::fun_encapsulator<RT,std_cxx1x::tuple<Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7>,7> Threads::spawn | ( | C & | c, | |
RT(C::*)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7) | fun_ptr | |||
) | [inline] |
Overload of the non-const spawn function for member functions with 7 arguments.
internal::fun_encapsulator<RT, std_cxx1x::tuple<Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7>,7> Threads::spawn | ( | const C & | c, | |
RT(C::*)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7) const | fun_ptr | |||
) | [inline] |
Overload of the spawn function for const member functions with 7 arguments.
internal::fun_encapsulator<RT,std_cxx1x::tuple<Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8>,8> Threads::spawn | ( | RT(*)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8) | fun_ptr | ) | [inline] |
Overload of the spawn function for non-member or static member functions with 8 arguments.
internal::fun_encapsulator<RT,std_cxx1x::tuple<Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8>,8> Threads::spawn | ( | C & | c, | |
RT(C::*)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8) | fun_ptr | |||
) | [inline] |
Overload of the non-const spawn function for member functions with 8 arguments.
internal::fun_encapsulator<RT, std_cxx1x::tuple<Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8>,8> Threads::spawn | ( | const C & | c, | |
RT(C::*)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8) const | fun_ptr | |||
) | [inline] |
Overload of the spawn function for const member functions with 8 arguments.
internal::fun_encapsulator<RT,std_cxx1x::tuple<Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9>,9> Threads::spawn | ( | RT(*)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9) | fun_ptr | ) | [inline] |
Overload of the spawn function for non-member or static member functions with 9 arguments.
internal::fun_encapsulator<RT,std_cxx1x::tuple<Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9>,9> Threads::spawn | ( | C & | c, | |
RT(C::*)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9) | fun_ptr | |||
) | [inline] |
Overload of the non-const spawn function for member functions with 9 arguments.
internal::fun_encapsulator<RT, std_cxx1x::tuple<Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9>,9> Threads::spawn | ( | const C & | c, | |
RT(C::*)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9) const | fun_ptr | |||
) | [inline] |
Overload of the spawn function for const member functions with 9 arguments.