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

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 Methods

 ACE_Dev_Poll_Reactor_Handler_Repository (void)
 Constructor. More...

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

int close (void)
 Close down the repository. More...

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

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

Repository Manipulation Operations
Methods used to search and modify the handler repository.

ACE_Event_Handlerfind (ACE_HANDLE handle, size_t *index_p=0)
void mask (ACE_HANDLE handle, ACE_Reactor_Mask mask)
 Set the event mask for event handler associated with the given handle. More...

ACE_Reactor_Mask mask (ACE_HANDLE handle)
 Retrieve the event mask for the event handler associated with the given handle. More...

void suspend (ACE_HANDLE handle)
 Mark the event handler associated with the given handle as "suspended.". More...

void resume (ACE_HANDLE handle)
 Mark the event handler associated with the given handle as "resumed.". More...

int suspended (ACE_HANDLE handle) const
 Is the event handler for the given handle suspended? More...

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

int unbind (ACE_HANDLE handle)
 Remove the binding of ACE_HANDLE in accordance with the <mask>. More...

int unbind_all (void)
 Remove all the (ACE_HANDLE, ACE_Event_Handler) tuples. More...

unsigned long add_ref (ACE_HANDLE handle)
 Increase the reference count on the event handler corresponding to the given file descriptor. More...

unsigned long remove_ref (ACE_HANDLE handle)
 Decrease the reference count on the event handler corresponding to the given file descriptor. More...

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


Private Attributes

int max_size_
 Maximum number of handles. More...

ACE_Dev_Poll_Event_Tuplehandlers_
 The underlying array of event handlers. More...


Detailed Description

Used to map ACE_HANDLEs onto the appropriate ACE_Event_Handler *.

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 318 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 598 of file Dev_Poll_Reactor.cpp.

References ACE_TRACE.

00599   : max_size_ (0),
00600     handlers_ (0)
00601 {
00602   ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::ACE_Dev_Poll_Reactor_Handler_Repository");
00603 }


Member Function Documentation

ACE_INLINE unsigned long ACE_Dev_Poll_Reactor_Handler_Repository::add_ref ACE_HANDLE    handle
 

Increase the reference count on the event handler corresponding to the given file descriptor.

Returns:
Returns the updated reference count.

Definition at line 95 of file Dev_Poll_Reactor.inl.

References handle_in_range, handlers_, and ACE_Dev_Poll_Event_Tuple::refcount.

Referenced by ACE_Dev_Poll_Handler_Guard::ACE_Dev_Poll_Handler_Guard.

00096 {
00097   // ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::add_ref");
00098 
00099   // Caller provides synchronization
00100 
00101   if (this->handle_in_range (handle))
00102     return this->handlers_[handle].refcount++;
00103 
00104   return 0;
00105 }

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 705 of file Dev_Poll_Reactor.cpp.

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

Referenced by ACE_Dev_Poll_Reactor::register_handler_i.

00709 {
00710   ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::bind");
00711 
00712   if (handle == ACE_INVALID_HANDLE)
00713     handle = event_handler->get_handle ();
00714 
00715   if (this->invalid_handle (handle))
00716     return -1;
00717 
00718   this->handlers_[handle].event_handler = event_handler;
00719   this->handlers_[handle].mask = mask;
00720 
00721   return 0;
00722 }

int ACE_Dev_Poll_Reactor_Handler_Repository::close void   
 

Close down the repository.

Definition at line 667 of file Dev_Poll_Reactor.cpp.

References ACE_TRACE, handlers_, and unbind_all.

Referenced by ACE_Dev_Poll_Reactor::close.

00668 {
00669   ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::close");
00670 
00671   if (this->handlers_ != 0)
00672     {
00673       this->unbind_all ();
00674 
00675       delete [] this->handlers_;
00676       this->handlers_ = 0;
00677     }
00678 
00679   return 0;
00680 }

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 683 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_events, 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.

00685 {
00686   ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::find");
00687 
00688   ACE_Event_Handler *eh = 0;
00689 
00690   // Only bother to search for the <handle> if it's in range.
00691   if (this->handle_in_range (handle))
00692     {
00693       eh = this->handlers_[handle].event_handler;
00694 
00695       if (eh != 0 && index_p != 0)
00696         *index_p = handle;
00697       else
00698         errno = ENOENT;
00699     }
00700 
00701   return eh;
00702 }

int ACE_Dev_Poll_Reactor_Handler_Repository::handle_in_range ACE_HANDLE    handle const
 

Definition at line 621 of file Dev_Poll_Reactor.cpp.

References ACE_TRACE, and max_size_.

Referenced by add_ref, find, mask, ACE_Dev_Poll_Reactor::mask_ops_i, remove_ref, resume, suspend, and suspended.

00623 {
00624   ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::handle_in_range");
00625 
00626   if (handle >= 0 && handle < this->max_size_)
00627     return 1;
00628   else
00629     {
00630       errno = EINVAL;
00631       return 0;
00632     }
00633 }

int ACE_Dev_Poll_Reactor_Handler_Repository::invalid_handle ACE_HANDLE    handle const
 

Definition at line 606 of file Dev_Poll_Reactor.cpp.

References ACE_TRACE, and max_size_.

Referenced by bind.

00608 {
00609   ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::invalid_handle");
00610 
00611   if (handle < 0 || handle >= this->max_size_)
00612     {
00613       errno = EINVAL;
00614       return 1;
00615     }
00616   else
00617     return 0;
00618 }

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 39 of file Dev_Poll_Reactor.inl.

References ACE_Reactor_Mask, ACE_TRACE, handle_in_range, handlers_, ACE_Dev_Poll_Event_Tuple::mask, mask, and ACE_Event_Handler::NULL_MASK.

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

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 28 of file Dev_Poll_Reactor.inl.

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

Referenced by bind, mask, ACE_Dev_Poll_Reactor::mask_ops_i, ACE_Dev_Poll_Reactor::remove_handler_i, and ACE_Dev_Poll_Reactor::resume_handler_i.

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

int ACE_Dev_Poll_Reactor_Handler_Repository::open size_t    size
 

Initialize a repository of the appropriate <size>.

Definition at line 636 of file Dev_Poll_Reactor.cpp.

References ACE_NEW_RETURN, ACE_TRACE, max_size_, ACE::set_handle_limit, and size.

Referenced by ACE_Dev_Poll_Reactor::open.

00637 {
00638   ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::open");
00639 
00640   this->max_size_ = size;
00641 
00642   // Try to allocate the memory.
00643   ACE_NEW_RETURN (this->handlers_,
00644                   ACE_Dev_Poll_Event_Tuple[size],
00645                   -1);
00646 
00647   // Try to increase the number of handles if <size> is greater than
00648   // the current limit.
00649   return ACE::set_handle_limit (size);
00650 }

ACE_INLINE unsigned long ACE_Dev_Poll_Reactor_Handler_Repository::remove_ref ACE_HANDLE    handle
 

Decrease the reference count on the event handler corresponding to the given file descriptor.

Returns:
Returns the updated reference count.

Definition at line 108 of file Dev_Poll_Reactor.inl.

References ACE_ASSERT, handle_in_range, handlers_, ACE_Dev_Poll_Event_Tuple::refcount, and unbind.

Referenced by ACE_Dev_Poll_Handler_Guard::~ACE_Dev_Poll_Handler_Guard.

00109 {
00110   // ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::remove_ref");
00111 
00112   // Caller provides synchronization
00113 
00114   if (this->handle_in_range (handle))
00115     {
00116       unsigned long & refcount = this->handlers_[handle].refcount;
00117 
00118       ACE_ASSERT  (refcount > 0);
00119 
00120       refcount--;
00121 
00122       if (refcount != 0)
00123         return refcount;
00124 
00125       // Reference count dropped to zero.  Remove the event handler
00126       // from the repository.
00127       this->unbind (handle);
00128     }
00129 
00130   return 0;
00131 }

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

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

ACE_INLINE size_t ACE_Dev_Poll_Reactor_Handler_Repository::size void    const
 

Returns the current table size.

Definition at line 87 of file Dev_Poll_Reactor.inl.

References ACE_TRACE, and max_size_.

Referenced by open, ACE_Dev_Poll_Reactor::resume_handlers, and ACE_Dev_Poll_Reactor::suspend_handlers.

00088 {
00089   ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::size");
00090 
00091   return this->max_size_;
00092 }

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

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

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

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

int ACE_Dev_Poll_Reactor_Handler_Repository::unbind ACE_HANDLE    handle
 

Remove the binding of ACE_HANDLE in accordance with the <mask>.

Definition at line 725 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::NULL_MASK, and ACE_Dev_Poll_Event_Tuple::suspended.

Referenced by ACE_Dev_Poll_Reactor::register_handler_i, ACE_Dev_Poll_Reactor::remove_handler_i, remove_ref, and unbind_all.

00726 {
00727   ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::unbind");
00728 
00729   if (this->find (handle) == 0)
00730     return -1;
00731 
00732   this->handlers_[handle].event_handler = 0;
00733   this->handlers_[handle].mask = ACE_Event_Handler::NULL_MASK;
00734   this->handlers_[handle].suspended = 0;
00735 
00736   return 0;
00737 }

int ACE_Dev_Poll_Reactor_Handler_Repository::unbind_all void   
 

Remove all the (ACE_HANDLE, ACE_Event_Handler) tuples.

Definition at line 653 of file Dev_Poll_Reactor.cpp.

References ACE_TRACE, max_size_, and unbind.

Referenced by close.

00654 {
00655   ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::unbind_all");
00656 
00657   // Unbind all of the event handlers.
00658   for (int handle = 0;
00659        handle < this->max_size_;
00660        ++handle)
00661     this->unbind (handle);
00662 
00663   return 0;
00664 }


Member Data Documentation

ACE_Dev_Poll_Reactor_Handler_Repository::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Definition at line 418 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 430 of file Dev_Poll_Reactor.h.

Referenced by add_ref, bind, close, find, mask, remove_ref, resume, suspend, suspended, and unbind.

int ACE_Dev_Poll_Reactor_Handler_Repository::max_size_ [private]
 

Maximum number of handles.

Definition at line 423 of file Dev_Poll_Reactor.h.

Referenced by handle_in_range, invalid_handle, open, size, and unbind_all.


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