ACE_Test_and_Set< ACE_LOCK, TYPE > Class Template Reference

Implements the classic ``test and set'' operation. More...

#include <Test_and_Set.h>

Inheritance diagram for ACE_Test_and_Set< ACE_LOCK, TYPE >:

Inheritance graph
[legend]
Collaboration diagram for ACE_Test_and_Set< ACE_LOCK, TYPE >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ACE_Test_and_Set (TYPE initial_value=0)
TYPE is_set (void) const
 Returns true if we are set, else false.
TYPE set (TYPE)
virtual int handle_signal (int signum, siginfo_t *=0, ucontext_t *=0)

Private Attributes

TYPE is_set_
 Keeps track of our state.
ACE_LOCK lock_
 Protect the state from race conditions.

Detailed Description

template<class ACE_LOCK, class TYPE>
class ACE_Test_and_Set< ACE_LOCK, TYPE >

Implements the classic ``test and set'' operation.

This class keeps track of the status of <is_set_>, which can be set based on various events (such as receipt of a signal). This class is derived from ACE_Event_Handler so that it can be "signaled" by a Reactor when a signal occurs. We assume that <TYPE> is a data type that can be assigned the value 0 or 1.

Definition at line 38 of file Test_and_Set.h.


Constructor & Destructor Documentation

template<class ACE_LOCK, class TYPE>
ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_Test_and_Set< ACE_LOCK, TYPE >::ACE_Test_and_Set ( TYPE  initial_value = 0  ) 

Definition at line 16 of file Test_and_Set.cpp.

00017   : is_set_ (initial_value)
00018 {
00019 }


Member Function Documentation

template<class ACE_LOCK, class TYPE>
int ACE_Test_and_Set< ACE_LOCK, TYPE >::handle_signal ( int  signum,
siginfo_t = 0,
ucontext_t = 0 
) [virtual]

Called when object is signaled by OS (either via UNIX signals or when a Win32 object becomes signaled).

Reimplemented from ACE_Event_Handler.

Definition at line 40 of file Test_and_Set.cpp.

References ACE_Test_and_Set< ACE_LOCK, TYPE >::set().

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 }

template<class ACE_LOCK, class TYPE>
TYPE ACE_Test_and_Set< ACE_LOCK, TYPE >::is_set ( void   )  const

Returns true if we are set, else false.

Definition at line 23 of file Test_and_Set.cpp.

References ACE_GUARD_RETURN, and ACE_Test_and_Set< ACE_LOCK, TYPE >::is_set_.

00024 {
00025   ACE_GUARD_RETURN (ACE_LOCK, ace_mon, (ACE_LOCK &) this->lock_, this->is_set_);
00026   return this->is_set_;
00027 }

template<class ACE_LOCK, class TYPE>
TYPE ACE_Test_and_Set< ACE_LOCK, TYPE >::set ( TYPE   ) 

Sets the <is_set_> status, returning the original value of <is_set_>.

Definition at line 31 of file Test_and_Set.cpp.

References ACE_GUARD_RETURN, and ACE_Test_and_Set< ACE_LOCK, TYPE >::is_set_.

Referenced by ACE_Test_and_Set< ACE_LOCK, TYPE >::handle_signal().

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 }


Member Data Documentation

template<class ACE_LOCK, class TYPE>
TYPE ACE_Test_and_Set< ACE_LOCK, TYPE >::is_set_ [private]

Keeps track of our state.

Definition at line 58 of file Test_and_Set.h.

Referenced by ACE_Test_and_Set< ACE_LOCK, TYPE >::is_set(), and ACE_Test_and_Set< ACE_LOCK, TYPE >::set().

template<class ACE_LOCK, class TYPE>
ACE_LOCK ACE_Test_and_Set< ACE_LOCK, TYPE >::lock_ [private]

Protect the state from race conditions.

Definition at line 61 of file Test_and_Set.h.


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:35:44 2010 for ACE by  doxygen 1.4.7