STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
stdext::threads::thread_group Class Reference

Public Member Functions

 thread_group ()
 
 ~thread_group () _NOEXCEPT
 
template<class _Func >
threadcreate_thread (_Func _Fp)
 
void add_thread (thread *_Thrd)
 
void remove_thread (thread *_Thrd)
 
void join_all ()
 

Private Member Functions

 thread_group (const thread_group &)
 
thread_groupoperator= (const thread_group &)
 

Static Private Member Functions

static void destroy (thread *_Thrd)
 
static void join (thread *_Thrd)
 

Private Attributes

mutex _Mtx
 
_STD vector< thread * > _Elts
 

Constructor & Destructor Documentation

stdext::threads::thread_group::thread_group ( )
inline
84  { // construct
85  }
stdext::threads::thread_group::~thread_group ( )
inline
88  { // destroy all owned threads
89  _STD vector<thread *>::iterator _Next = _Elts.begin();
91  for (; _Next != _End; ++_Next)
92  destroy(*_Next);
93  }
Definition: vector:287
_STD vector< thread * > _Elts
Definition: thread:146
static void destroy(thread *_Thrd)
Definition: thread:151
stdext::threads::thread_group::thread_group ( const thread_group )
private

Member Function Documentation

void stdext::threads::thread_group::add_thread ( thread _Thrd)
inline
120  { // add a thread
121  _THREAD_ASSERT(_Thrd->_Joinable,
122  "threads::thread_group::add_thread called "
123  "with non-joinable thread");
125  if (_STD find(_Elts.begin(), _Elts.end(), _Thrd) == _Elts.end())
126  _Elts.push_back(_Thrd);
127  }
#define _THREAD_ASSERT(expr, msg)
Definition: xthrcommon.h:66
mutex _Mtx
Definition: thread:145
void lock(_Lock0 &_Lk0, _Lock1 &_Lk1, _LockN &..._LkN)
Definition: mutex:417
_STD vector< thread * > _Elts
Definition: thread:146
_Scoped_lock scoped_lock
Definition: allocators:34
_InIt find(_InIt _First, _InIt _Last, const _Ty &_Val)
Definition: xutility:3050
template<class _Func >
thread* stdext::threads::thread_group::create_thread ( _Func  _Fp)
inline
97  { // create a new thread
98  thread *_Thr = 0;
99 
100  #if _HAS_EXCEPTIONS
101  try { // don't let exceptions escape
102  _Thr = new thread(_Fp);
103  add_thread(_Thr);
104  }
105  catch (...)
106  { // delete incomplete thread
107  delete _Thr;
108  throw;
109  }
110 
111  #else /* _HAS_EXCEPTIONS */
112  _Thr = new thread(_Fp);
113  add_thread(_Thr);
114  #endif /* _HAS_EXCEPTIONS */
115 
116  return (_Thr);
117  }
void add_thread(thread *_Thrd)
Definition: thread:119
Definition: thread:31
static void stdext::threads::thread_group::destroy ( thread _Thrd)
inlinestaticprivate
152  { // delete a pointer to thread
153  delete _Thrd;
154  }
static void stdext::threads::thread_group::join ( thread _Thrd)
inlinestaticprivate
157  { // join a thread
158  _Thrd->join();
159  }
void join()
Definition: thread:206
void stdext::threads::thread_group::join_all ( )
inline
136  { // join all threads
138  _STD vector<thread *>::iterator _Next = _Elts.begin();
140  for (; _Next != _End; ++_Next)
141  join(*_Next);
142  }
Definition: vector:287
mutex _Mtx
Definition: thread:145
void lock(_Lock0 &_Lk0, _Lock1 &_Lk1, _LockN &..._LkN)
Definition: mutex:417
_STD vector< thread * > _Elts
Definition: thread:146
_Scoped_lock scoped_lock
Definition: allocators:34
static void join(thread *_Thrd)
Definition: thread:156
thread_group& stdext::threads::thread_group::operator= ( const thread_group )
private
void stdext::threads::thread_group::remove_thread ( thread _Thrd)
inline
130  { // remove a thread
132  _Elts.erase(_STD find(_Elts.begin(), _Elts.end(), _Thrd));
133  }
mutex _Mtx
Definition: thread:145
void lock(_Lock0 &_Lk0, _Lock1 &_Lk1, _LockN &..._LkN)
Definition: mutex:417
_STD vector< thread * > _Elts
Definition: thread:146
_Scoped_lock scoped_lock
Definition: allocators:34
_InIt find(_InIt _First, _InIt _Last, const _Ty &_Val)
Definition: xutility:3050

Member Data Documentation

_STD vector<thread *> stdext::threads::thread_group::_Elts
private
mutex stdext::threads::thread_group::_Mtx
private

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