Initial Patch of Auction House bot rev. 135
[auctionmangos.git] / dep / ACE_wrappers / ace / Event.h
blob887b504d8f9c90333e0473e8f7060dc1f7e161dc
1 // -*- C++ -*-
3 //==========================================================================
4 /**
5 * @file Event.h
7 * $Id: Event.h 80826 2008-03-04 14:51:23Z wotte $
9 * Moved from Synch.h.
11 * @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
13 //==========================================================================
15 #ifndef ACE_EVENT_H
16 #define ACE_EVENT_H
17 #include /**/ "ace/pre.h"
19 #include /**/ "ace/ACE_export.h"
21 #if !defined (ACE_LACKS_PRAGMA_ONCE)
22 # pragma once
23 #endif /* ACE_LACKS_PRAGMA_ONCE */
25 #include "ace/OS_NS_Thread.h"
27 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
29 /**
30 * @class ACE_Event
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
41 public:
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,
47 void *arg = 0,
48 LPSECURITY_ATTRIBUTES sa = 0);
50 /// Implicitly destroy the event variable.
51 ~ACE_Event (void);
53 /**
54 * Explicitly destroy the event variable. Note that only one thread
55 * should call this method since it doesn't protect against race
56 * conditions.
58 int remove (void);
60 /// Underlying handle to event.
61 ACE_event_t handle (void) const;
63 /**
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
69 * overwriting it.
71 void handle (ACE_event_t new_handle);
73 /**
74 * if MANUAL reset
75 * sleep till the event becomes signaled
76 * event remains signaled after wait() completes.
77 * else AUTO reset
78 * sleep till the event becomes signaled
79 * event resets wait() completes.
81 int wait (void);
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);
89 /**
90 * if MANUAL reset
91 * wake up all waiting threads
92 * set to signaled state
93 * else AUTO reset
94 * if no thread is waiting, set to signaled state
95 * if thread(s) are waiting, wake up one waiting thread and
96 * reset event
98 int signal (void);
101 * if MANUAL reset
102 * wakeup all waiting threads and
103 * reset event
104 * else AUTO reset
105 * wakeup one waiting thread (if present) and
106 * reset event
108 int pulse (void);
110 /// Set to nonsignaled state.
111 int reset (void);
113 /// Dump the state of an object.
114 void dump (void) const;
116 /// Declare the dynamic allocation hooks
117 ACE_ALLOC_HOOK_DECLARE;
119 protected:
120 /// The underlying handle.
121 ACE_event_t 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...
128 bool removed_;
130 private:
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 */