![]() |
Home | Libraries | People | FAQ | More |
#include <boost/thread/thread.hpp> class thread_group { public: thread_group(const thread_group&) = delete; thread_group& operator=(const thread_group&) = delete; thread_group(); ~thread_group(); template<typename F> thread* create_thread(F threadfunc); void add_thread(thread* thrd); void remove_thread(thread* thrd); bool is_this_thread_in(); bool is_thread_in(thread* thrd); void join_all(); void interrupt_all(); int size() const; };
thread_group
provides for
a collection of threads that are related in some fashion. New threads can
be added to the group with add_thread
and create_thread
member
functions. thread_group
is
not copyable or movable.
~thread_group();
Destroy *this
and delete
all boost::thread
objects in the group.
template<typename F> thread* create_thread(F threadfunc);
Create a new boost::thread
object as-if by
new thread(threadfunc)
and add it to the group.
this->size()
is increased by one, the new thread is running.
A pointer to the new boost::thread
object.
void add_thread(thread* thrd);
The expression delete thrd
is well-formed and will not
result in undefined behaviour and is_thread_in(thrd) == false
.
Take ownership of the boost::thread
object pointed to
by thrd
and add it
to the group.
this->size()
is increased by one.
void remove_thread(thread* thrd);
If thrd
is a member
of the group, remove it without calling delete
.
If thrd
was a member
of the group, this->size()
is decreased by one.
void join_all();
is_this_thread_in() == false
.
Call join()
on each boost::thread
object in the group.
Every thread in the group has terminated.
Since join()
is one of the predefined interruption
points, join_all()
is also an interruption point.
bool is_this_thread_in();
true if there is a thread th
in the group such that th.get_id() == this_thread::get_id()
.
bool is_thread_in(thread* thrd);
true if there is a thread th
in the group such that th.get_id() == thrd->get_id()
.
void interrupt_all();
Call interrupt()
on each boost::thread
object in the group.