Test_and_Set.cpp

Go to the documentation of this file.
00001 // Test_and_Set.cpp,v 4.7 2005/10/28 23:55:10 ossama Exp
00002 
00003 #ifndef ACE_TEST_AND_SET_CPP
00004 #define ACE_TEST_AND_SET_CPP
00005 
00006 #include "ace/Test_and_Set.h"
00007 #include "ace/Guard_T.h"
00008 
00009 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00010 # pragma once
00011 #endif /* ACE_LACKS_PRAGMA_ONCE */
00012 
00013 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00014 
00015 template <class ACE_LOCK, class TYPE>
00016 ACE_Test_and_Set<ACE_LOCK, TYPE>::ACE_Test_and_Set (TYPE initial_value)
00017   : is_set_ (initial_value)
00018 {
00019 }
00020 
00021 // Returns true if we are done, else false.
00022 template <class ACE_LOCK, class TYPE> TYPE
00023 ACE_Test_and_Set<ACE_LOCK, TYPE>::is_set (void) const
00024 {
00025   ACE_GUARD_RETURN (ACE_LOCK, ace_mon, (ACE_LOCK &) this->lock_, this->is_set_);
00026   return this->is_set_;
00027 }
00028 
00029 // Sets the <is_set_> status.
00030 template <class ACE_LOCK, class TYPE> TYPE
00031 ACE_Test_and_Set<ACE_LOCK, TYPE>::set (TYPE status)
00032 {
00033   ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, this->is_set_);
00034   TYPE o_status = this->is_set_;
00035   this->is_set_ = status;
00036   return o_status;
00037 }
00038 
00039 template <class ACE_LOCK, class TYPE> int
00040 ACE_Test_and_Set<ACE_LOCK, TYPE>::handle_signal (int, siginfo_t *, ucontext_t *)
00041 {
00042   // By setting this to 1, we are "signaling" to anyone calling
00043   // <is_set> or or <set> that the "test and set" object is in the
00044   // "signaled" state, i.e., it's "available" to be set back to 0.
00045   this->set (1);
00046   return 0;
00047 }
00048 
00049 ACE_END_VERSIONED_NAMESPACE_DECL
00050 
00051 #endif /* ACE_TEST_AND_SET_CPP */

Generated on Thu Nov 9 09:42:06 2006 for ACE by doxygen 1.3.6