Changeset 5925 for branches/newapi

Show
Ignore:
Timestamp:
12/03/07 07:51:06 (12 months ago)
Author:
erijo
Message:

Added class Licq::Thread::Current with method exit for operating on calling thread.

Location:
branches/newapi/licq
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • branches/newapi/licq/licq/thread/thread.h

    r5920 r5925  
    7373  }; 
    7474 
     75  class Current 
     76  { 
     77  public: 
     78    /** 
     79     * Exits the calling thread. 
     80     * 
     81     * @param status The thread's exit status. 
     82     */ 
     83    static void exit(int status) LICQ_NO_RETURN; 
     84  }; 
     85 
    7586  class Entry 
    7687  { 
  • branches/newapi/licq/src/thread/thread.cpp

    r5609 r5925  
    3232#include <signal.h> 
    3333 
     34void Licq::Thread::Current::exit(int status) 
     35{ 
     36  ::pthread_exit(reinterpret_cast<void*>(status)); 
     37} 
     38 
    3439void Licq::Thread::Entry::exit(int status) 
    3540{ 
    36   ::pthread_exit(new int(status)); 
     41  Licq::Thread::Current::exit(status); 
    3742} 
    3843 
     
    131136  static void* threadStartRoutine(void* arg) 
    132137  { 
     138    // Unblock SIGTERM 
     139    sigset_t mask; 
     140    sigemptyset(&mask); 
     141    sigaddset(&mask, SIGTERM); 
     142    DBG(const int error =) ::pthread_sigmask(SIG_UNBLOCK, &mask, NULL); 
     143    assert(error == 0); 
     144 
    133145    Licq::Thread::Entry* entry = static_cast<Licq::Thread::Entry*>(arg); 
    134146    int ret = -1; 
     
    141153      // Empty 
    142154    } 
    143     return new int(ret); 
     155    return reinterpret_cast<void*>(ret); 
    144156  } 
    145157 
     
    186198    { 
    187199      myState = StateJoined; 
    188       int* iret = static_cast<int*>(ret); 
    189       int status = *iret; 
    190       delete iret; 
    191       return status; 
     200      return reinterpret_cast<int>(ret); 
    192201    } 
    193202  }