Fixed typos
[ACE_TAO.git] / ACE / ace / Test_and_Set.h
blob6ec541a697ebe8af33c87b01cbb52390d37706a1
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 (void) 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,
49 siginfo_t * = 0,
50 ucontext_t * = 0);
52 private:
53 /// Keeps track of our state.
54 TYPE is_set_;
56 /// Protect the state from race conditions.
57 ACE_LOCK lock_;
60 ACE_END_VERSIONED_NAMESPACE_DECL
62 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
63 #include "ace/Test_and_Set.cpp"
64 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
66 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
67 #pragma implementation ("Test_and_Set.cpp")
68 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
70 #include /**/ "ace/post.h"
71 #endif /* ACE_TEST_AND_SET_H */