9 #include "pthread/thread.hpp" 
   15   namespace this_thread {
 
   18       usleep(millis * 1000); 
 
   22       return pthread_self();
 
   38       int rc = pthread_join(_thread, NULL);
 
   46             throw thread_exception(
"EDEADLKpthread_join failed because of deadlock conditions.", rc );
 
   48             throw thread_exception(
"EINVEL pthread_join failed not a joinable thread.", rc );
 
   52             throw thread_exception(
"pthread_join returned an unexpected return code.", rc);
 
   66     rc = pthread_cancel ( _thread );
 
   85     rc = pthread_attr_init(&_attr);
 
   90     rc = pthread_attr_setdetachstate(&_attr, PTHREAD_CREATE_JOINABLE);
 
   95     rc = pthread_attr_setstacksize(&_attr, stack_size);
 
   96     if ( (stack_size > 0) && (rc != 0) ){
 
   97       throw thread_exception(
"bad stacksize, check size passed to thread::thread; thread not started.", rc );
 
  116       pthread_attr_destroy(&_attr);
 
  127   void thread::swap(
thread& other){
 
  128     std::swap(_thread, other._thread);
 
  129     std::swap(_status, other._status);
 
  135   abstract_thread::~abstract_thread(){
 
  137     if ( _thread != NULL ){
 
  152     return _thread != 0 ;
 
  155 #if __cplusplus < 201103L 
  165     while(! _threads.empty()){
 
  167 #if __cplusplus < 201103L 
  168       std::auto_ptr<pthread::abstract_thread> pat(_threads.front());
 
  170       std::unique_ptr<pthread::abstract_thread> pat(_threads.front());
 
  173       _threads.pop_front();
 
  175       if ( _destructor_joins_first && pat->joinable() ){
 
  181           printf(
"thread_group destructor received an unexpected exception when joining threads.");
 
  189     _threads.push_back(thread);
 
  193       for(
auto iterator = _threads.begin(); iterator != _threads.end(); iterator++){
 
  194         (*iterator)->start();
 
  199     for(
auto iterator = _threads.begin(); iterator != _threads.end(); iterator++){
 
  200       if ( (*iterator)->joinable() ){
 
  207     return _threads.size();
 
  218       static_cast<runnable *
>(runner)->run();
 
  220       printf(
"uncaugth excpetion in thread_startup_runnable(), check your runnable::run() implementation.");
 
void sleep_for(const int millis)
virtual int pthread_errno()
virtual const char * what() const noexceptoverride
void add(abstract_thread *thread)
void * thread_startup_runnable(void *)
thread_group(bool destructor_joins_first=false) noexcept
abstract_thread(const std::size_t stack_size=0)
thread & operator=(const thread &)=delete
virtual const char * pthread_errmsg()