Defines a platform-independent thread ID class. Note that this class should be defined within the scope of a thread, rather than at global scope! More...
#include <OS_NS_Thread.h>
Public Member Functions | |
ACE_Thread_ID (ACE_thread_t thr_id, ACE_hthread_t thr_handle) | |
ACE_Thread_ID (void) | |
Initialize the object using calls to ACE_OS::thr_self(). | |
ACE_Thread_ID (const ACE_Thread_ID &rhs) | |
Copy constructor. | |
ACE_thread_t | id (void) const |
Get the thread id. | |
void | id (ACE_thread_t) |
Set the thread id. | |
ACE_hthread_t | handle (void) const |
Get the thread handle. | |
void | handle (ACE_hthread_t) |
Set the thread handle. | |
void | to_string (char *thr_string) const |
bool | operator== (const ACE_Thread_ID &) const |
Equality operator. | |
bool | operator!= (const ACE_Thread_ID &) const |
Inequality operator. | |
Private Attributes | |
ACE_thread_t | thread_id_ |
Identify the thread. | |
ACE_hthread_t | thread_handle_ |
Handle to the thread (typically used to "wait" on Win32). |
Defines a platform-independent thread ID class. Note that this class should be defined within the scope of a thread, rather than at global scope!
Definition at line 686 of file OS_NS_Thread.h.
ACE_Thread_ID::ACE_Thread_ID | ( | ACE_thread_t | thr_id, | |
ACE_hthread_t | thr_handle | |||
) |
Initialize the object using the thread id and thread handle passed as parameters.
Definition at line 3588 of file OS_NS_Thread.inl.
: thread_id_ (thread_id), thread_handle_ (thread_handle) { }
ACE_Thread_ID::ACE_Thread_ID | ( | void | ) |
Initialize the object using calls to ACE_OS::thr_self().
Definition at line 3603 of file OS_NS_Thread.inl.
: thread_id_ (ACE_OS::thr_self ()) { ACE_OS::thr_self (thread_handle_); }
ACE_Thread_ID::ACE_Thread_ID | ( | const ACE_Thread_ID & | rhs | ) |
Copy constructor.
Definition at line 3596 of file OS_NS_Thread.inl.
: thread_id_ (id.thread_id_), thread_handle_ (id.thread_handle_) { }
ACE_hthread_t ACE_Thread_ID::handle | ( | void | ) | const |
Get the thread handle.
Definition at line 3623 of file OS_NS_Thread.inl.
{ return this->thread_handle_; }
void ACE_Thread_ID::handle | ( | ACE_hthread_t | thread_handle | ) |
Set the thread handle.
Definition at line 3629 of file OS_NS_Thread.inl.
{ this->thread_handle_ = thread_handle; }
void ACE_Thread_ID::id | ( | ACE_thread_t | thread_id | ) |
Set the thread id.
Definition at line 3617 of file OS_NS_Thread.inl.
{ this->thread_id_ = thread_id; }
ACE_thread_t ACE_Thread_ID::id | ( | void | ) | const |
bool ACE_Thread_ID::operator!= | ( | const ACE_Thread_ID & | rhs | ) | const |
bool ACE_Thread_ID::operator== | ( | const ACE_Thread_ID & | rhs | ) | const |
Equality operator.
Definition at line 3635 of file OS_NS_Thread.inl.
{ return ACE_OS::thr_cmp (this->thread_handle_, rhs.thread_handle_) && ACE_OS::thr_equal (this->thread_id_, rhs.thread_id_); }
void ACE_Thread_ID::to_string | ( | char * | thr_string | ) | const |
Definition at line 53 of file OS_NS_Thread.cpp.
{ char format[128]; // Converted format string char *fp = 0; // Current format pointer fp = format; *fp++ = '%'; // Copy in the % #if defined (ACE_WIN32) ACE_OS::strcpy (fp, "u"); ACE_OS::sprintf (thr_string, format, static_cast <unsigned> (thread_id_)); #elif defined (DIGITAL_UNIX) ACE_OS::strcpy (fp, "u"); ACE_OS::sprintf (thr_string, format, # if defined (ACE_HAS_THREADS) thread_id_ # else thread_id_ # endif /* ACE_HAS_THREADS */ ); #else # if defined (ACE_MVS) || defined (ACE_TANDEM_T1248_PTHREADS) // MVS's pthread_t is a struct... yuck. So use the ACE 5.0 // code for it. ACE_OS::strcpy (fp, "u"); ACE_OS::sprintf (thr_string, format, thread_handle_); # else // Yes, this is an ugly C-style cast, but the // correct C++ cast is different depending on // whether the t_id is an integral type or a pointer // type. FreeBSD uses a pointer type, but doesn't // have a _np function to get an integral type, like // the OSes above. ACE_OS::strcpy (fp, "lu"); ACE_OS::sprintf (thr_string, format, (unsigned long) thread_handle_); # endif /* ACE_MVS || ACE_TANDEM_T1248_PTHREADS */ #endif /* ACE_WIN32 */ }
ACE_hthread_t ACE_Thread_ID::thread_handle_ [private] |
Handle to the thread (typically used to "wait" on Win32).
Definition at line 726 of file OS_NS_Thread.h.
ACE_thread_t ACE_Thread_ID::thread_id_ [private] |
Identify the thread.
Definition at line 723 of file OS_NS_Thread.h.