3 //==========================================================================
7 * $Id: Event.h 80826 2008-03-04 14:51:23Z wotte $
11 * @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
13 //==========================================================================
17 #include /**/ "ace/pre.h"
19 #include /**/ "ace/ACE_export.h"
21 #if !defined (ACE_LACKS_PRAGMA_ONCE)
23 #endif /* ACE_LACKS_PRAGMA_ONCE */
25 #include "ace/OS_NS_Thread.h"
27 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
32 * @brief A wrapper around the Win32 event locking mechanism.
34 * Portable implementation of an Event mechanism, which is native to
35 * Win32, but must be emulated on UNIX. All platforms support
36 * process-scope locking support. However, only Win32 platforms
37 * support global naming and system-scope locking support.
39 class ACE_Export ACE_Event
42 /// Constructor that creates event.
43 ACE_Event (int manual_reset
= 0,
44 int initial_state
= 0,
45 int type
= USYNC_THREAD
,
46 const ACE_TCHAR
*name
= 0,
48 LPSECURITY_ATTRIBUTES sa
= 0);
50 /// Implicitly destroy the event variable.
54 * Explicitly destroy the event variable. Note that only one thread
55 * should call this method since it doesn't protect against race
60 /// Underlying handle to event.
61 ACE_event_t
handle (void) const;
64 * Set the underlying handle to event. Note that this method assumes
65 * ownership of the <handle> and will close it down in <remove>. If
66 * you want the <handle> to stay open when <remove> is called make
67 * sure to call <dup> on the <handle> before closing it. You are
68 * responsible for the closing the existing <handle> before
71 void handle (ACE_event_t new_handle
);
75 * sleep till the event becomes signaled
76 * event remains signaled after wait() completes.
78 * sleep till the event becomes signaled
79 * event resets wait() completes.
83 /// Same as wait() above, but this one can be timed
84 /// @a abstime is absolute time-of-day if if @a use_absolute_time
85 /// is non-0, else it is relative time.
86 int wait (const ACE_Time_Value
*abstime
,
87 int use_absolute_time
= 1);
91 * wake up all waiting threads
92 * set to signaled state
94 * if no thread is waiting, set to signaled state
95 * if thread(s) are waiting, wake up one waiting thread and
102 * wakeup all waiting threads and
105 * wakeup one waiting thread (if present) and
110 /// Set to nonsignaled state.
113 /// Dump the state of an object.
114 void dump (void) const;
116 /// Declare the dynamic allocation hooks
117 ACE_ALLOC_HOOK_DECLARE
;
120 /// The underlying handle.
123 /// Keeps track of whether <remove> has been called yet to avoid
124 /// multiple <remove> calls, e.g., explicitly and implicitly in the
125 /// destructor. This flag isn't protected by a lock, so make sure
126 /// that you don't have multiple threads simultaneously calling
127 /// <remove> on the same object, which is a bad idea anyway...
131 // = Prevent copying.
132 ACE_Event (const ACE_Event
& event
);
133 const ACE_Event
&operator= (const ACE_Event
&rhs
);
136 ACE_END_VERSIONED_NAMESPACE_DECL
138 #if defined (__ACE_INLINE__)
139 #include "ace/Event.inl"
140 #endif /* __ACE_INLINE__ */
142 #include /**/ "ace/post.h"
143 #endif /* ACE_EVENT_H */