ACE_Event Class Reference

A wrapper around the Win32 event locking mechanism. More...

#include <Event.h>

Inheritance diagram for ACE_Event:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 ACE_Event (int manual_reset=0, int initial_state=0, int type=USYNC_THREAD, const ACE_TCHAR *name=0, void *arg=0)
 Constructor that creates event.

 ~ACE_Event (void)
 Implicitly destroy the event variable.

int remove (void)
ACE_event_t handle (void) const
 Underlying handle to event.

void handle (ACE_event_t new_handle)
int wait (void)
int wait (const ACE_Time_Value *abstime, int use_absolute_time=1)
int signal (void)
int pulse (void)
int reset (void)
 Set to nonsignaled state.

void dump (void) const
 Dump the state of an object.


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.


Protected Attributes

ACE_event_t handle_
 The underlying handle.

int removed_

Private Member Functions

 ACE_Event (const ACE_Event &event)
const ACE_Eventoperator= (const ACE_Event &rhs)

Detailed Description

A wrapper around the Win32 event locking mechanism.

Portable implementation of an Event mechanism, which is native to Win32, but must be emulated on UNIX. All platforms support process-scope locking support. However, only Win32 platforms support global naming and system-scope locking support.

Definition at line 39 of file Event.h.


Constructor & Destructor Documentation

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_Event::ACE_Event int  manual_reset = 0,
int  initial_state = 0,
int  type = USYNC_THREAD,
const ACE_TCHAR name = 0,
void *  arg = 0
 

Constructor that creates event.

Definition at line 15 of file Event.cpp.

References ACE_ERROR, ACE_LIB_TEXT, ACE_TCHAR, ACE_OS::event_init(), and LM_ERROR.

00020   : removed_ (0)
00021 {
00022   if (ACE_OS::event_init (&this->handle_,
00023                           manual_reset,
00024                           initial_state,
00025                           type,
00026                           name,
00027                           arg) != 0)
00028     ACE_ERROR ((LM_ERROR,
00029                 ACE_LIB_TEXT ("%p\n"),
00030                 ACE_LIB_TEXT ("ACE_Event::ACE_Event")));
00031 }

ACE_Event::~ACE_Event void   ) 
 

Implicitly destroy the event variable.

Definition at line 33 of file Event.cpp.

References remove().

00034 {
00035   this->remove ();
00036 }

ACE_Event::ACE_Event const ACE_Event event  )  [private]
 


Member Function Documentation

void ACE_Event::dump void   )  const
 

Dump the state of an object.

Reimplemented in ACE_Auto_Event, and ACE_Manual_Event.

Definition at line 83 of file Event.cpp.

References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, and LM_DEBUG.

Referenced by ACE_Manual_Event::dump(), and ACE_Auto_Event::dump().

00084 {
00085 #if defined (ACE_HAS_DUMP)
00086   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00087   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00088 #endif /* ACE_HAS_DUMP */
00089 }

ACE_INLINE void ACE_Event::handle ACE_event_t  new_handle  ) 
 

Set the underlying handle to event. Note that this method assumes ownership of the and will close it down in . If you want the to stay open when is called make sure to call on the before closing it. You are responsible for the closing the existing before overwriting it.

Definition at line 13 of file Event.inl.

00014 {
00015   this->handle_ = new_handle;
00016 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE ACE_event_t ACE_Event::handle void   )  const
 

Underlying handle to event.

Definition at line 7 of file Event.inl.

Referenced by ACE_WIN32_Proactor::get_handle(), ACE_WFMO_Reactor_Notify::get_handle(), ACE_WFMO_Reactor_Notify::handle_signal(), and ACE_WFMO_Reactor::open().

00008 {
00009   return this->handle_;
00010 }

const ACE_Event& ACE_Event::operator= const ACE_Event rhs  )  [private]
 

int ACE_Event::pulse void   ) 
 

if MANUAL reset wakeup all waiting threads and reset event else AUTO reset wakeup one waiting thread (if present) and reset event

Definition at line 71 of file Event.cpp.

References ACE_OS::event_pulse().

00072 {
00073   return ACE_OS::event_pulse (&this->handle_);
00074 }

int ACE_Event::remove void   ) 
 

Explicitly destroy the event variable. Note that only one thread should call this method since it doesn't protect against race conditions.

Definition at line 39 of file Event.cpp.

References ACE_OS::event_destroy().

Referenced by ~ACE_Event().

00040 {
00041   int result = 0;
00042   if (this->removed_ == 0)
00043     {
00044       this->removed_ = 1;
00045       result = ACE_OS::event_destroy (&this->handle_);
00046     }
00047   return result;
00048 }

int ACE_Event::reset void   ) 
 

Set to nonsignaled state.

Definition at line 77 of file Event.cpp.

References ACE_OS::event_reset().

Referenced by ACE_WFMO_Reactor::open(), and ACE_WFMO_Reactor::update_state().

00078 {
00079   return ACE_OS::event_reset (&this->handle_);
00080 }

int ACE_Event::signal void   ) 
 

if MANUAL reset wake up all waiting threads set to signaled state else AUTO reset if no thread is waiting, set to signaled state if thread(s) are waiting, wake up one waiting thread and reset event

Definition at line 65 of file Event.cpp.

References ACE_OS::event_signal().

Referenced by ACE_WFMO_Reactor_Notify::handle_signal(), ACE_WFMO_Reactor_Notify::notify(), ACE_Proactor::schedule_timer(), ACE_WFMO_Reactor::update_state(), ACE_WFMO_Reactor::wakeup_all_threads(), and ACE_Proactor_Timer_Handler::~ACE_Proactor_Timer_Handler().

00066 {
00067   return ACE_OS::event_signal (&this->handle_);
00068 }

int ACE_Event::wait const ACE_Time_Value abstime,
int  use_absolute_time = 1
 

Same as wait() above, but this one can be timed abstime is absolute time-of-day if if use_absolute_time is non-0, else it is relative time.

Definition at line 57 of file Event.cpp.

References ACE_OS::event_timedwait().

00058 {
00059   return ACE_OS::event_timedwait (&this->handle_,
00060                                   const_cast <ACE_Time_Value *> (abstime),
00061                                   use_absolute_time);
00062 }

int ACE_Event::wait void   ) 
 

if MANUAL reset sleep till the event becomes signaled event remains signaled after wait() completes. else AUTO reset sleep till the event becomes signaled event resets wait() completes.

Definition at line 51 of file Event.cpp.

References ACE_OS::event_wait().

Referenced by ACE_Proactor_Timer_Handler::svc(), and ACE_WFMO_Reactor::update_state().

00052 {
00053   return ACE_OS::event_wait (&this->handle_);
00054 }


Member Data Documentation

ACE_Event::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Reimplemented in ACE_Auto_Event, and ACE_Manual_Event.

Definition at line 116 of file Event.h.

ACE_event_t ACE_Event::handle_ [protected]
 

The underlying handle.

Definition at line 120 of file Event.h.

int ACE_Event::removed_ [protected]
 

Keeps track of whether has been called yet to avoid multiple calls, e.g., explicitly and implicitly in the destructor. This flag isn't protected by a lock, so make sure that you don't have multiple threads simultaneously calling on the same object, which is a bad idea anyway...

Definition at line 127 of file Event.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:22:02 2006 for ACE by doxygen 1.3.6