3 //=============================================================================
7 //=============================================================================
10 #ifndef ACE_TEST_AND_SET_H
11 #define ACE_TEST_AND_SET_H
13 #include /**/ "ace/pre.h"
14 #include "ace/Event_Handler.h"
16 #if !defined (ACE_LACKS_PRAGMA_ONCE)
18 #endif /* ACE_LACKS_PRAGMA_ONCE */
20 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
23 * @class ACE_Test_and_Set
25 * @brief Implements the classic ``test and set'' operation.
27 * This class keeps track of the status of <is_set_>, which can be
28 * set based on various events (such as receipt of a signal).
29 * This class is derived from ACE_Event_Handler so that it can be
30 * "signaled" by a Reactor when a signal occurs. We assume that
31 * <TYPE> is a data type that can be assigned the value 0 or 1.
33 template <class ACE_LOCK
, class TYPE
>
34 class ACE_Test_and_Set
: public ACE_Event_Handler
37 ACE_Test_and_Set (TYPE initial_value
= 0);
39 /// Returns true if we are set, else false.
42 /// Sets the <is_set_> status, returning the original value of
46 /// Called when object is signaled by OS (either via UNIX signals or
47 /// when a Win32 object becomes signaled).
48 virtual int handle_signal (int signum
, siginfo_t
* = 0, ucontext_t
* = 0);
51 /// Keeps track of our state.
54 /// Protect the state from race conditions.
58 ACE_END_VERSIONED_NAMESPACE_DECL
60 #include "ace/Test_and_Set.cpp"
62 #include /**/ "ace/post.h"
63 #endif /* ACE_TEST_AND_SET_H */