Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tao / CSD_ThreadPool / CSD_TP_Synch_Helper.h
blob78e658283672a1b003b4dff821f84ccd465cbb2a
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file CSD_TP_Synch_Helper.h
7 * @author Tim Bradley <bradley_t@ociweb.com>
8 */
9 //=============================================================================
11 #ifndef TAO_CSD_TP_SYNCH_HELPER_H
12 #define TAO_CSD_TP_SYNCH_HELPER_H
14 #include /**/ "ace/pre.h"
16 #include "tao/CSD_ThreadPool/CSD_TP_Export.h"
17 #include "tao/Condition.h"
19 #if !defined (ACE_LACKS_PRAGMA_ONCE)
20 # pragma once
21 #endif /* ACE_LACKS_PRAGMA_ONCE */
23 #include "ace/Synch.h"
25 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
27 namespace TAO
29 namespace CSD
31 /**
32 * @class TP_Synch_Helper
34 * @brief Helper class for synchronous requests to block the requesting
35 * thread until the appropriate time (when it will be un-blocked).
37 * TBD - Description here
40 class TAO_CSD_TP_Export TP_Synch_Helper
42 public:
43 /// Constructor. Sets initial state to PENDING.
44 TP_Synch_Helper();
46 /// Destructor.
47 ~TP_Synch_Helper();
49 /// Returns true if the helper state is DISPATCHED, and false if
50 /// the helper state is CANCELLED. However, if the helper state
51 /// is PENDING, then this method will block the calling thread
52 /// until the state changes to something other than PENDING
53 /// (ie, DISPATCHED or CANCELLED).
54 bool wait_while_pending();
56 /// Change the state of this helper to DISPATCHED, which will cause
57 /// wait_while_pending() to unblock.
58 void dispatched();
60 /// Change the state of this helper to CANCELLED, which will cause
61 /// wait_while_pending() to unblock.
62 void cancelled();
64 private:
65 /// Enumeration Type for all possible states of this helper object.
66 enum HelperState
68 PENDING,
69 DISPATCHED,
70 CANCELLED
73 /// Thread lock type
74 typedef TAO_SYNCH_MUTEX LockType;
76 /// Thread condition type
77 typedef TAO_Condition<LockType> ConditionType;
79 /// Lock used to protect the state and condition.
80 LockType lock_;
82 /// Used to denote the state of the request dispatching.
83 HelperState state_;
85 /// The condition used to block the calling thread until the
86 /// state is something other than the PENDING state.
87 ConditionType condition_;
92 TAO_END_VERSIONED_NAMESPACE_DECL
94 #if defined (__ACE_INLINE__)
95 # include "tao/CSD_ThreadPool/CSD_TP_Synch_Helper.inl"
96 #endif /* __ACE_INLINE__ */
98 #include /**/ "ace/post.h"
100 #endif /* TAO_CSD_TP_SYNCH_HELPER_H */