
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 623 of file OS_NS_Thread.cpp.
|
|
Definition at line 651 of file OS_NS_Thread.cpp.
00652 {
00653 FLAG_DELETING = 1,
00654 FLAG_VALID_CHECKED = 2
00655 };
|
|
|
Definition at line 626 of file OS_NS_Thread.cpp.
|
|
|
Definition at line 658 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().
00659 : ptr_(0) 00660 , flags_(0) 00661 { 00662 // During static construction or construction of the ACE_Object_Manager, 00663 // there can be only one thread in this constructor at any one time, so 00664 // it's safe to check for a zero mutex_. If it's zero, we create a new 00665 // mutex and condition variable. 00666 if (mutex_ == 0) 00667 { 00668 ACE_NEW (mutex_, ACE_Thread_Mutex ()); 00669 ACE_NEW (condition_, ACE_Thread_Condition<ACE_Thread_Mutex> (*mutex_)); 00670 } 00671 00672 ACE_Guard<ACE_Thread_Mutex> guard(*mutex_); 00673 00674 if (purpose == CREATE) 00675 { 00676 if (instance_ == 0) 00677 { 00678 instance_ = new ACE_TSS_Cleanup(); 00679 } 00680 ptr_ = instance_; 00681 ++reference_count_; 00682 } 00683 else if(purpose == DESTROY) 00684 { 00685 if (instance_ != 0) 00686 { 00687 ptr_ = instance_; 00688 instance_ = 0; 00689 ACE_SET_BITS(flags_, FLAG_DELETING); 00690 while (reference_count_ > 0) 00691 { 00692 condition_->wait(); 00693 } 00694 } 00695 } 00696 else // must be normal use 00697 { 00698 ACE_ASSERT(purpose == USE); 00699 if (instance_ != 0) 00700 { 00701 ptr_ = instance_; 00702 ++reference_count_; 00703 } 00704 } 00705 } |
|
|
Definition at line 707 of file OS_NS_Thread.cpp. References ACE_ASSERT, ACE_BIT_ENABLED, condition_, FLAG_DELETING, and ACE_Condition< ACE_Thread_Mutex >::signal().
00708 {
00709 // Variable to hold the mutex_ to delete outside the scope of the
00710 // guard.
00711 ACE_Thread_Mutex *del_mutex = 0;
00712
00713 // scope the guard
00714 {
00715 ACE_Guard<ACE_Thread_Mutex> guard (*mutex_);
00716 if (ptr_ != 0)
00717 {
00718 if (ACE_BIT_ENABLED (flags_, FLAG_DELETING))
00719 {
00720 ACE_ASSERT(instance_ == 0);
00721 ACE_ASSERT(reference_count_ == 0);
00722 delete ptr_;
00723 del_mutex = mutex_ ;
00724 mutex_ = 0;
00725 }
00726 else
00727 {
00728 ACE_ASSERT (reference_count_ > 0);
00729 --reference_count_;
00730 if (reference_count_ == 0 && instance_ == 0)
00731 condition_->signal ();
00732 }
00733 }
00734 }// end of guard scope
00735
00736 if (del_mutex != 0)
00737 {
00738 delete condition_;
00739 condition_ = 0;
00740 delete del_mutex;
00741 }
00742 }
|
|
|
Definition at line 752 of file OS_NS_Thread.cpp. References ACE_ASSERT, ACE_BIT_ENABLED, and FLAG_VALID_CHECKED.
00753 {
00754 ACE_ASSERT(ACE_BIT_ENABLED(flags_, FLAG_VALID_CHECKED));
00755 return instance_;
00756 }
|
|
|
Definition at line 759 of file OS_NS_Thread.cpp. References ACE_ASSERT, ACE_BIT_ENABLED, and FLAG_VALID_CHECKED.
00760 {
00761 ACE_ASSERT(ACE_BIT_ENABLED(flags_, FLAG_VALID_CHECKED));
00762 return instance_;
00763 }
|
|
|
Definition at line 745 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().
00746 {
00747 ACE_SET_BITS(flags_, FLAG_VALID_CHECKED);
00748 return (this->instance_ != 0);
00749 }
|
|
|
Definition at line 769 of file OS_NS_Thread.cpp. Referenced by TSS_Cleanup_Instance(), and ~TSS_Cleanup_Instance(). |
|
|
Definition at line 650 of file OS_NS_Thread.cpp. |
|
|
Definition at line 767 of file OS_NS_Thread.cpp. |
|
|
Definition at line 768 of file OS_NS_Thread.cpp. |
|
|
Definition at line 649 of file OS_NS_Thread.cpp. |
|
|
Definition at line 766 of file OS_NS_Thread.cpp. |
1.3.6