Public Types | |
enum | Purpose { CREATE, USE, DESTROY } |
Public Member Functions | |
TSS_Cleanup_Instance (Purpose purpose=USE) | |
~TSS_Cleanup_Instance () | |
bool | valid () |
ACE_TSS_Cleanup * | operator-> () |
Private Types | |
enum | { FLAG_DELETING = 1, FLAG_VALID_CHECKED = 2 } |
Private Member Functions | |
ACE_TSS_Cleanup * | operator * () |
Private Attributes | |
ACE_TSS_Cleanup * | ptr_ |
unsigned short | flags_ |
Static Private Attributes | |
unsigned int | reference_count_ = 0 |
ACE_TSS_Cleanup * | instance_ = 0 |
ACE_Thread_Mutex * | mutex_ = 0 |
ACE_Thread_Condition< ACE_Thread_Mutex > * | condition_ = 0 |
Definition at line 676 of file OS_NS_Thread.cpp.
|
Definition at line 704 of file OS_NS_Thread.cpp.
00705 { 00706 FLAG_DELETING = 1, 00707 FLAG_VALID_CHECKED = 2 00708 }; |
|
Definition at line 679 of file OS_NS_Thread.cpp.
|
|
Definition at line 711 of file OS_NS_Thread.cpp. References ACE_ASSERT, ACE_NEW, ACE_SET_BITS, condition_, CREATE, DESTROY, FLAG_DELETING, USE, and ACE_Condition< ACE_Thread_Mutex >::wait().
00712 : ptr_(0) 00713 , flags_(0) 00714 { 00715 // During static construction or construction of the ACE_Object_Manager, 00716 // there can be only one thread in this constructor at any one time, so 00717 // it's safe to check for a zero mutex_. If it's zero, we create a new 00718 // mutex and condition variable. 00719 if (mutex_ == 0) 00720 { 00721 ACE_NEW (mutex_, ACE_Thread_Mutex ()); 00722 ACE_NEW (condition_, ACE_Thread_Condition<ACE_Thread_Mutex> (*mutex_)); 00723 } 00724 00725 ACE_Guard<ACE_Thread_Mutex> guard(*mutex_); 00726 00727 if (purpose == CREATE) 00728 { 00729 if (instance_ == 0) 00730 { 00731 instance_ = new ACE_TSS_Cleanup(); 00732 } 00733 ptr_ = instance_; 00734 ++reference_count_; 00735 } 00736 else if(purpose == DESTROY) 00737 { 00738 if (instance_ != 0) 00739 { 00740 ptr_ = instance_; 00741 instance_ = 0; 00742 ACE_SET_BITS(flags_, FLAG_DELETING); 00743 while (reference_count_ > 0) 00744 { 00745 condition_->wait(); 00746 } 00747 } 00748 } 00749 else // must be normal use 00750 { 00751 ACE_ASSERT(purpose == USE); 00752 if (instance_ != 0) 00753 { 00754 ptr_ = instance_; 00755 ++reference_count_; 00756 } 00757 } 00758 } |
|
Definition at line 760 of file OS_NS_Thread.cpp. References ACE_ASSERT, ACE_BIT_ENABLED, condition_, FLAG_DELETING, and ACE_Condition< ACE_Thread_Mutex >::signal().
00761 { 00762 // Variable to hold the mutex_ to delete outside the scope of the 00763 // guard. 00764 ACE_Thread_Mutex *del_mutex = 0; 00765 00766 // scope the guard 00767 { 00768 ACE_Guard<ACE_Thread_Mutex> guard (*mutex_); 00769 if (ptr_ != 0) 00770 { 00771 if (ACE_BIT_ENABLED (flags_, FLAG_DELETING)) 00772 { 00773 ACE_ASSERT(instance_ == 0); 00774 ACE_ASSERT(reference_count_ == 0); 00775 delete ptr_; 00776 del_mutex = mutex_ ; 00777 mutex_ = 0; 00778 } 00779 else 00780 { 00781 ACE_ASSERT (reference_count_ > 0); 00782 --reference_count_; 00783 if (reference_count_ == 0 && instance_ == NULL) 00784 condition_->signal (); 00785 } 00786 } 00787 }// end of guard scope 00788 00789 if (del_mutex != 0) 00790 { 00791 delete condition_; 00792 condition_ = 0; 00793 delete del_mutex; 00794 } 00795 } |
|
Definition at line 805 of file OS_NS_Thread.cpp. References ACE_ASSERT, ACE_BIT_ENABLED, and FLAG_VALID_CHECKED.
00806 { 00807 ACE_ASSERT(ACE_BIT_ENABLED(flags_, FLAG_VALID_CHECKED)); 00808 return instance_; 00809 } |
|
Definition at line 812 of file OS_NS_Thread.cpp. References ACE_ASSERT, ACE_BIT_ENABLED, and FLAG_VALID_CHECKED.
00813 { 00814 ACE_ASSERT(ACE_BIT_ENABLED(flags_, FLAG_VALID_CHECKED)); 00815 return instance_; 00816 } |
|
Definition at line 798 of file OS_NS_Thread.cpp. References ACE_SET_BITS, and FLAG_VALID_CHECKED. Referenced by ACE_OS::cleanup_tss(), ACE_OS::thr_key_detach(), ACE_OS::thr_key_used(), ACE_OS::thr_keycreate(), ACE_OS::thr_keyfree(), and ACE_OS::thr_setspecific().
00799 { 00800 ACE_SET_BITS(flags_, FLAG_VALID_CHECKED); 00801 return (this->instance_ != NULL); 00802 } |
|
Definition at line 822 of file OS_NS_Thread.cpp. Referenced by TSS_Cleanup_Instance(), and ~TSS_Cleanup_Instance(). |
|
Definition at line 703 of file OS_NS_Thread.cpp. |
|
Definition at line 820 of file OS_NS_Thread.cpp. |
|
Definition at line 821 of file OS_NS_Thread.cpp. |
|
Definition at line 702 of file OS_NS_Thread.cpp. |
|
Definition at line 819 of file OS_NS_Thread.cpp. |