Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

ACE_Event Class Reference

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

#include <Synch.h>

Inheritance diagram for ACE_Event:

Inheritance graph
[legend]
List of all members.

Public Methods

 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. More...

 ~ACE_Event (void)
 Implicitly destroy the event variable. More...

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

void handle (ACE_event_t new_handle)
int wait (void)
int 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. More...

int signal (void)
int pulse (void)
int reset (void)
 Set to nonsignaled state. More...

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


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks. More...


Protected Attributes

ACE_event_t handle_
 The underlying handle. More...

int removed_
 Keeps track of whether <remove> has been called yet to avoid multiple <remove> 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 <remove> on the same object, which is a bad idea anyway... More...


Private Methods

 ACE_Event (const ACE_Event &event)
const ACE_Event & operator= (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 828 of file Synch.h.


Constructor & Destructor Documentation

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 269 of file Synch.cpp.

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

00274   : removed_ (0)
00275 {
00276   if (ACE_OS::event_init (&this->handle_,
00277                           manual_reset,
00278                           initial_state,
00279                           type,
00280                           name,
00281                           arg) != 0)
00282     ACE_ERROR ((LM_ERROR,
00283                 ACE_LIB_TEXT ("%p\n"),
00284                 ACE_LIB_TEXT ("ACE_Event::ACE_Event")));
00285 }

ACE_Event::~ACE_Event void   
 

Implicitly destroy the event variable.

Definition at line 287 of file Synch.cpp.

References remove.

00288 {
00289   this->remove ();
00290 }

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_Manual_Event.

Definition at line 349 of file Synch.cpp.

References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, and LM_DEBUG.

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

00350 {
00351   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00352   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00353 }

void ACE_Event::handle ACE_event_t    new_handle
 

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

Definition at line 311 of file Synch.cpp.

References handle_.

00312 {
00313   this->handle_ = new_handle;
00314 }

ACE_event_t ACE_Event::handle void    const
 

Underlying handle to event.

Definition at line 305 of file Synch.cpp.

References handle_.

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

00306 {
00307   return this->handle_;
00308 }

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 337 of file Synch.cpp.

References ACE_OS::event_pulse.

00338 {
00339   return ACE_OS::event_pulse (&this->handle_);
00340 }

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 293 of file Synch.cpp.

References ACE_OS::event_destroy, and removed_.

Referenced by ~ACE_Event.

00294 {
00295   int result = 0;
00296   if (this->removed_ == 0)
00297     {
00298       this->removed_ = 1;
00299       result = ACE_OS::event_destroy (&this->handle_);
00300     }
00301   return result;
00302 }

int ACE_Event::reset void   
 

Set to nonsignaled state.

Definition at line 343 of file Synch.cpp.

References ACE_OS::event_reset.

Referenced by ACE_WFMO_Reactor::open, ACE_Asynch_Pseudo_Task::stop, and ACE_WFMO_Reactor::update_state.

00344 {
00345   return ACE_OS::event_reset (&this->handle_);
00346 }

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 331 of file Synch.cpp.

References ACE_OS::event_signal.

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

00332 {
00333   return ACE_OS::event_signal (&this->handle_);
00334 }

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 323 of file Synch.cpp.

References ACE_OS::event_timedwait.

00324 {
00325   return ACE_OS::event_timedwait (&this->handle_,
00326                                   (ACE_Time_Value *) abstime,
00327                                   use_absolute_time);
00328 }

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 317 of file Synch.cpp.

References ACE_OS::event_wait.

Referenced by ACE_Asynch_Pseudo_Task::stop, ACE_Proactor_Timer_Handler::svc, and ACE_WFMO_Reactor::update_state.

00318 {
00319   return ACE_OS::event_wait (&this->handle_);
00320 }


Member Data Documentation

ACE_Event::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Reimplemented in ACE_Manual_Event.

Definition at line 905 of file Synch.h.

ACE_event_t ACE_Event::handle_ [protected]
 

The underlying handle.

Definition at line 909 of file Synch.h.

Referenced by handle.

int ACE_Event::removed_ [protected]
 

Keeps track of whether <remove> has been called yet to avoid multiple <remove> 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 <remove> on the same object, which is a bad idea anyway...

Definition at line 916 of file Synch.h.

Referenced by remove.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:47:41 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002