Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / Test_and_Set.h
blobc174ca3d4dae96bd585666704f562eb921220791
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file Test_and_Set.h
6 */
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)
17 # pragma once
18 #endif /* ACE_LACKS_PRAGMA_ONCE */
20 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
22 /**
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
36 public:
37 ACE_Test_and_Set (TYPE initial_value = 0);
39 /// Returns true if we are set, else false.
40 TYPE is_set () const;
42 /// Sets the <is_set_> status, returning the original value of
43 /// <is_set_>.
44 TYPE set (TYPE);
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);
50 private:
51 /// Keeps track of our state.
52 TYPE is_set_;
54 /// Protect the state from race conditions.
55 ACE_LOCK lock_;
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 */