ACE_Dev_Poll_Reactor_Handler_Repository Class Reference

Used to map ACE_HANDLEs onto the appropriate ACE_Event_Handler *. More...

#include <Dev_Poll_Reactor.h>

Collaboration diagram for ACE_Dev_Poll_Reactor_Handler_Repository:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ACE_Dev_Poll_Reactor_Handler_Repository (void)
 Constructor.

int open (size_t size)
 Initialize a repository of the appropriate .

int close (void)
 Close down the repository.

size_t size (void) const
 Returns the current table size.

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

Repository Manipulation Operations
ACE_Event_Handlerfind (ACE_HANDLE handle, size_t *index_p=0)
void mask (ACE_HANDLE handle, ACE_Reactor_Mask mask)
ACE_Reactor_Mask mask (ACE_HANDLE handle)
void suspend (ACE_HANDLE handle)
void resume (ACE_HANDLE handle)
int suspended (ACE_HANDLE handle) const
 Is the event handler for the given handle suspended?

int bind (ACE_HANDLE handle, ACE_Event_Handler *handler, ACE_Reactor_Mask mask)
int unbind (ACE_HANDLE handle, bool decr_refcnt=true)
int unbind_all (void)
 Remove all the (ACE_HANDLE, ACE_Event_Handler) tuples.

Sanity Checking
Methods used to prevent "out-of-range" errors when indexing the underlying handler array.

int invalid_handle (ACE_HANDLE handle) const
int handle_in_range (ACE_HANDLE handle) const

Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.


Private Attributes

int max_size_
 Maximum number of handles.

ACE_Dev_Poll_Event_Tuplehandlers_
 The underlying array of event handlers.


Detailed Description

Used to map ACE_HANDLEs onto the appropriate ACE_Event_Handler *.

For internal use only.

This class is simply a container that maps a handle to its corresponding event handler. It is not meant for use outside of the Dev_Poll_Reactor.

Definition at line 330 of file Dev_Poll_Reactor.h.


Constructor & Destructor Documentation

ACE_Dev_Poll_Reactor_Handler_Repository::ACE_Dev_Poll_Reactor_Handler_Repository void   ) 
 

Constructor.

Definition at line 578 of file Dev_Poll_Reactor.cpp.

References ACE_TRACE.

00579   : max_size_ (0),
00580     handlers_ (0)
00581 {
00582   ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::ACE_Dev_Poll_Reactor_Handler_Repository");
00583 }


Member Function Documentation

int ACE_Dev_Poll_Reactor_Handler_Repository::bind ACE_HANDLE  handle,
ACE_Event_Handler handler,
ACE_Reactor_Mask  mask
 

Bind the ACE_Event_Handler to the ACE_HANDLE with the appropriate ACE_Reactor_Mask settings.

Definition at line 687 of file Dev_Poll_Reactor.cpp.

References ACE_Reactor_Mask, ACE_TRACE, ACE_Event_Handler::add_reference(), ACE_Dev_Poll_Event_Tuple::event_handler, ACE_Event_Handler::get_handle(), handlers_, invalid_handle(), and ACE_Dev_Poll_Event_Tuple::mask.

Referenced by ACE_Dev_Poll_Reactor::register_handler_i().

00691 {
00692   ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::bind");
00693 
00694   if (handle == ACE_INVALID_HANDLE)
00695     handle = event_handler->get_handle ();
00696 
00697   if (this->invalid_handle (handle))
00698     return -1;
00699 
00700   this->handlers_[handle].event_handler = event_handler;
00701   this->handlers_[handle].mask = mask;
00702   event_handler->add_reference ();
00703 
00704   return 0;
00705 }

int ACE_Dev_Poll_Reactor_Handler_Repository::close void   ) 
 

Close down the repository.

Definition at line 647 of file Dev_Poll_Reactor.cpp.

References ACE_TRACE, handlers_, and unbind_all().

Referenced by ACE_Dev_Poll_Reactor::close().

00648 {
00649   ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::close");
00650 
00651   if (this->handlers_ != 0)
00652     {
00653       this->unbind_all ();
00654 
00655       delete [] this->handlers_;
00656       this->handlers_ = 0;
00657     }
00658 
00659   return 0;
00660 }

void ACE_Dev_Poll_Reactor_Handler_Repository::dump void   )  const
 

Dump the state of an object.

ACE_Event_Handler * ACE_Dev_Poll_Reactor_Handler_Repository::find ACE_HANDLE  handle,
size_t *  index_p = 0
 

Return the ACE_Event_Handler associated with ACE_HANDLE. If index_p is non-zero, then return the index location of the handle, if found.

Definition at line 663 of file Dev_Poll_Reactor.cpp.

References ACE_TRACE, ACE_Dev_Poll_Event_Tuple::event_handler, handle_in_range(), and handlers_.

Referenced by ACE_Dev_Poll_Reactor::dispatch_io_event(), ACE_Dev_Poll_Reactor::find_handler(), ACE_Dev_Poll_Reactor::handler(), ACE_Dev_Poll_Reactor::register_handler_i(), ACE_Dev_Poll_Reactor::remove_handler_i(), ACE_Dev_Poll_Reactor::resume_handler_i(), ACE_Dev_Poll_Reactor::suspend_handler_i(), and unbind().

00665 {
00666   ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::find");
00667 
00668   ACE_Event_Handler *eh = 0;
00669 
00670   // Only bother to search for the <handle> if it's in range.
00671   if (this->handle_in_range (handle))
00672     {
00673       eh = this->handlers_[handle].event_handler;
00674       if (eh != 0)
00675         {
00676           if (index_p != 0)
00677             *index_p = handle;
00678         }
00679       else
00680         errno = ENOENT;
00681     }
00682 
00683   return eh;
00684 }

int ACE_Dev_Poll_Reactor_Handler_Repository::handle_in_range ACE_HANDLE  handle  )  const
 

Definition at line 601 of file Dev_Poll_Reactor.cpp.

References ACE_TRACE.

Referenced by find(), mask(), ACE_Dev_Poll_Reactor::mask_ops_i(), resume(), suspend(), and suspended().

00603 {
00604   ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::handle_in_range");
00605 
00606   if (handle >= 0 && handle < this->max_size_)
00607     return 1;
00608   else
00609     {
00610       errno = EINVAL;
00611       return 0;
00612     }
00613 }

int ACE_Dev_Poll_Reactor_Handler_Repository::invalid_handle ACE_HANDLE  handle  )  const
 

Definition at line 586 of file Dev_Poll_Reactor.cpp.

References ACE_TRACE.

Referenced by bind().

00588 {
00589   ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::invalid_handle");
00590 
00591   if (handle < 0 || handle >= this->max_size_)
00592     {
00593       errno = EINVAL;
00594       return 1;
00595     }
00596   else
00597     return 0;
00598 }

ACE_INLINE ACE_Reactor_Mask ACE_Dev_Poll_Reactor_Handler_Repository::mask ACE_HANDLE  handle  ) 
 

Retrieve the event mask for the event handler associated with the given handle.

Definition at line 42 of file Dev_Poll_Reactor.inl.

References ACE_Reactor_Mask, ACE_TRACE, handle_in_range(), handlers_, and ACE_Dev_Poll_Event_Tuple::mask.

00043 {
00044   ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::mask");
00045 
00046   ACE_Reactor_Mask mask = ACE_Event_Handler::NULL_MASK;
00047 
00048   // Only bother to search for the handle if it's in range.
00049   if (this->handle_in_range (handle))
00050     mask = this->handlers_[handle].mask;
00051 
00052   if (mask == ACE_Event_Handler::NULL_MASK)
00053     errno = ENOENT;
00054 
00055   return mask;
00056 }

ACE_INLINE void ACE_Dev_Poll_Reactor_Handler_Repository::mask ACE_HANDLE  handle,
ACE_Reactor_Mask  mask
 

Set the event mask for event handler associated with the given handle.

Definition at line 31 of file Dev_Poll_Reactor.inl.

References ACE_Reactor_Mask, ACE_TRACE, handle_in_range(), handlers_, and ACE_Dev_Poll_Event_Tuple::mask.

Referenced by ACE_Dev_Poll_Reactor::mask_ops_i(), ACE_Dev_Poll_Reactor::remove_handler_i(), and ACE_Dev_Poll_Reactor::resume_handler_i().

00033 {
00034   ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::mask");
00035 
00036   // Only bother to search for the handle if it's in range.
00037   if (this->handle_in_range (handle))
00038     this->handlers_[handle].mask = mask;
00039 }

int ACE_Dev_Poll_Reactor_Handler_Repository::open size_t  size  ) 
 

Initialize a repository of the appropriate .

Definition at line 616 of file Dev_Poll_Reactor.cpp.

References ACE_NEW_RETURN, ACE_TRACE, and ACE::set_handle_limit().

Referenced by ACE_Dev_Poll_Reactor::open().

00617 {
00618   ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::open");
00619 
00620   this->max_size_ = size;
00621 
00622   // Try to allocate the memory.
00623   ACE_NEW_RETURN (this->handlers_,
00624                   ACE_Dev_Poll_Event_Tuple[size],
00625                   -1);
00626 
00627   // Try to increase the number of handles if <size> is greater than
00628   // the current limit.
00629   return ACE::set_handle_limit (size);
00630 }

ACE_INLINE void ACE_Dev_Poll_Reactor_Handler_Repository::resume ACE_HANDLE  handle  ) 
 

Mark the event handler associated with the given handle as "resumed."

Definition at line 69 of file Dev_Poll_Reactor.inl.

References ACE_TRACE, handle_in_range(), handlers_, and ACE_Dev_Poll_Event_Tuple::suspended.

Referenced by ACE_Dev_Poll_Reactor::resume_handler_i().

00070 {
00071   ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::resume");
00072 
00073   // Only bother to search for the handle if it's in range.
00074   if (this->handle_in_range (handle))
00075     this->handlers_[handle].suspended = 0;
00076 }

ACE_INLINE size_t ACE_Dev_Poll_Reactor_Handler_Repository::size void   )  const
 

Returns the current table size.

Definition at line 90 of file Dev_Poll_Reactor.inl.

References ACE_TRACE.

Referenced by ACE_Dev_Poll_Reactor::resume_handlers(), and ACE_Dev_Poll_Reactor::suspend_handlers().

00091 {
00092   ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::size");
00093 
00094   return this->max_size_;
00095 }

ACE_INLINE void ACE_Dev_Poll_Reactor_Handler_Repository::suspend ACE_HANDLE  handle  ) 
 

Mark the event handler associated with the given handle as "suspended."

Definition at line 59 of file Dev_Poll_Reactor.inl.

References ACE_TRACE, handle_in_range(), handlers_, and ACE_Dev_Poll_Event_Tuple::suspended.

Referenced by ACE_Dev_Poll_Reactor::suspend_handler_i().

00060 {
00061   ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::suspend");
00062 
00063   // Only bother to search for the handle if it's in range.
00064   if (this->handle_in_range (handle))
00065     this->handlers_[handle].suspended = 1;
00066 }

ACE_INLINE int ACE_Dev_Poll_Reactor_Handler_Repository::suspended ACE_HANDLE  handle  )  const
 

Is the event handler for the given handle suspended?

Definition at line 79 of file Dev_Poll_Reactor.inl.

References ACE_TRACE, handle_in_range(), handlers_, and ACE_Dev_Poll_Event_Tuple::suspended.

Referenced by ACE_Dev_Poll_Reactor::mask_ops_i(), ACE_Dev_Poll_Reactor::resume_handler_i(), ACE_Dev_Poll_Reactor::resume_handlers(), ACE_Dev_Poll_Reactor::suspend_handler_i(), and ACE_Dev_Poll_Reactor::suspend_handlers().

00080 {
00081   ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::suspended");
00082 
00083   if (this->handle_in_range (handle))
00084     return this->handlers_[handle].suspended;
00085 
00086   return -1;
00087 }

int ACE_Dev_Poll_Reactor_Handler_Repository::unbind ACE_HANDLE  handle,
bool  decr_refcnt = true
 

Remove the binding for ACE_HANDLE; optionally decrement the associated handler's reference count.

Definition at line 708 of file Dev_Poll_Reactor.cpp.

References ACE_TRACE, ACE_Dev_Poll_Event_Tuple::event_handler, find(), handlers_, ACE_Dev_Poll_Event_Tuple::mask, ACE_Event_Handler::remove_reference(), and ACE_Dev_Poll_Event_Tuple::suspended.

Referenced by ACE_Dev_Poll_Reactor::register_handler_i(), ACE_Dev_Poll_Reactor::remove_handler_i(), and unbind_all().

00710 {
00711   ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::unbind");
00712 
00713   if (this->find (handle) == 0)
00714     return -1;
00715 
00716   if (decr_refcnt)
00717     this->handlers_[handle].event_handler->remove_reference ();
00718   this->handlers_[handle].event_handler = 0;
00719   this->handlers_[handle].mask = ACE_Event_Handler::NULL_MASK;
00720   this->handlers_[handle].suspended = 0;
00721 
00722   return 0;
00723 }

int ACE_Dev_Poll_Reactor_Handler_Repository::unbind_all void   ) 
 

Remove all the (ACE_HANDLE, ACE_Event_Handler) tuples.

Definition at line 633 of file Dev_Poll_Reactor.cpp.

References ACE_TRACE, and unbind().

Referenced by close().

00634 {
00635   ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::unbind_all");
00636 
00637   // Unbind all of the event handlers.
00638   for (int handle = 0;
00639        handle < this->max_size_;
00640        ++handle)
00641     this->unbind (handle);
00642 
00643   return 0;
00644 }


Member Data Documentation

ACE_Dev_Poll_Reactor_Handler_Repository::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Definition at line 416 of file Dev_Poll_Reactor.h.

ACE_Dev_Poll_Event_Tuple* ACE_Dev_Poll_Reactor_Handler_Repository::handlers_ [private]
 

The underlying array of event handlers.

The array of event handlers is directly indexed directly using an ACE_HANDLE value. This is Unix-specific.

Definition at line 428 of file Dev_Poll_Reactor.h.

Referenced by bind(), close(), find(), mask(), resume(), suspend(), suspended(), and unbind().

int ACE_Dev_Poll_Reactor_Handler_Repository::max_size_ [private]
 

Maximum number of handles.

Definition at line 421 of file Dev_Poll_Reactor.h.


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