boost.png (6897 bytes) Home Libraries People FAQ More

PrevUpHomeNext

Class thread_group

boost::thread_group — The thread_group class provides a container for easy grouping of threads to simplify several common thread creation and management idioms.

Synopsis

class thread_group : private boost::noncopyable   // Exposition only
{
public:
  // construct/copy/destruct
  thread_group();
  ~thread_group();

  // modifier
  thread* create_thread(const boost::function0<void>&);
  void add_thread(thread* thrd);
  void remove_thread(thread* thrd);
  void join_all();
};

Description

thread_group construct/copy/destruct

  1. thread_group();

    Effects: Constructs an empty thread_group container.

  2. ~thread_group();

    Effects: Destroys each contained thread object. Destroys *this.
    Notes: Behavior is undefined if another thread references *this during the execution of the destructor.

thread_group modifier

  1. thread* create_thread(const boost::function0<void>& threadfunc);

    Effects: Creates a new thread object that executes threadfunc and adds it to the thread_group container object's list of managed thread objects.
    Returns: Pointer to the newly created thread object.

  2. void add_thread(thread* thrd);

    Effects: Adds thrd to the thread_group object's list of managed thread objects. The thrd object must have been allocated via operator new and will be deleted when the group is destroyed.

  3. void remove_thread(thread* thrd);

    Effects: Removes thread from *this's list of managed thread objects.
    Throws: ??? if thrd is not in *this's list of managed thread objects.

  4. void join_all();

    Effects: Calls join() on each of the managed thread objects.

Copyright © 2001-2003 William E. Kempf

PrevUpHomeNext