#include <Handle_Set.h>
| Public Types | |
| enum | { MAXSIZE = ACE_DEFAULT_SELECT_REACTOR_SIZE } | 
| Public Member Functions | |
| ACE_Handle_Set (void) | |
| Constructor, initializes the bitmask to all 0s. | |
| ACE_Handle_Set (const fd_set &mask) | |
| void | reset (void) | 
| Initialize the bitmask to all 0s and reset the associated fields. | |
| int | is_set (ACE_HANDLE handle) const | 
| void | set_bit (ACE_HANDLE handle) | 
| void | clr_bit (ACE_HANDLE handle) | 
| int | num_set (void) const | 
| Returns a count of the number of enabled bits. | |
| ACE_HANDLE | max_set (void) const | 
| Returns the number of the large bit. | |
| void | sync (ACE_HANDLE max) | 
| operator fd_set * () | |
| fd_set * | fdset (void) | 
| void | dump (void) const | 
| Dump the state of an object. | |
| Public Attributes | |
| ACE_ALLOC_HOOK_DECLARE | |
| Declare the dynamic allocation hooks. | |
| Private Types | |
| enum | { WORDSIZE = NFDBITS, NBITS = 256 } | 
| Private Member Functions | |
| void | set_max (ACE_HANDLE max) | 
| Static Private Member Functions | |
| int | count_bits (u_long n) | 
| Private Attributes | |
| int | size_ | 
| Size of the set, i.e., a count of the number of enabled bits. | |
| ACE_HANDLE | max_handle_ | 
| Current max handle. | |
| fd_set | mask_ | 
| Bitmask. | |
| Static Private Attributes | |
| const char | nbits_ [NBITS] | 
| Friends | |
| class | ACE_Handle_Set_Iterator | 
This abstraction is a very efficient wrapper facade over . In particular, no range checking is performed, so it's important not to set or clear bits that are outside the ACE_DEFAULT_SELECT_REACTOR_SIZE. 
Definition at line 53 of file Handle_Set.h.
| 
 | 
| 
 Definition at line 60 of file Handle_Set.h. 
 00061   {
00062     MAXSIZE = ACE_DEFAULT_SELECT_REACTOR_SIZE
00063   };
 | 
| 
 | 
| 
 Definition at line 142 of file Handle_Set.h. 
 | 
| 
 | 
| Constructor, initializes the bitmask to all 0s. 
 Definition at line 98 of file Handle_Set.cpp. References ACE_TRACE, and reset(). 
 | 
| 
 | 
| Constructor, initializes the handle set from a given mask. Definition at line 104 of file Handle_Set.cpp. References ACE_TRACE, MAXSIZE, ACE_OS::memcpy(), reset(), and sync(). 
 00105 {
00106   ACE_TRACE ("ACE_Handle_Set::ACE_Handle_Set");
00107   this->reset ();
00108   ACE_OS::memcpy ((void *) &this->mask_,
00109                   (void *) &fd_mask,
00110                   sizeof this->mask_);
00111 #if !defined (ACE_WIN32)
00112   this->sync (ACE_Handle_Set::MAXSIZE);
00113 #if defined (ACE_HAS_BIG_FD_SET)
00114   this->min_handle_ = 0;
00115 #endif /* ACE_HAS_BIG_FD_SET */
00116 #endif /* !ACE_WIN32 */
00117 }
 | 
| 
 | 
| 
Disables the handle. No range checking is performed so handle must be less than  Definition at line 131 of file Handle_Set.inl. References ACE_TRACE, is_set(), max_handle_, and set_max(). Referenced by ACE_Select_Reactor_Impl::bit_ops(), ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::check_handles(), ACE_Select_Reactor_Impl::clear_dispatch_mask(), ACE_TP_Reactor::clear_handle_read_set(), ACE_Select_Reactor_Notify::dispatch_notifications(), ACE_TP_Reactor::handle_notify_events(), ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::resume_i(), and ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::suspend_i(). 
 00132 {
00133   ACE_TRACE ("ACE_Handle_Set::clr_bit");
00134 
00135   if ((handle != ACE_INVALID_HANDLE) &&
00136       (this->is_set (handle)))
00137     {
00138       FD_CLR ((ACE_SOCKET) handle,
00139               &this->mask_);
00140       --this->size_;
00141 
00142 #if !defined (ACE_WIN32)
00143       if (handle == this->max_handle_)
00144         this->set_max (this->max_handle_);
00145 #endif /* !ACE_WIN32 */
00146     }
00147 }
 | 
| 
 | 
| Counts the number of bits enabled in N. Uses a table lookup to speed up the count. Definition at line 123 of file Handle_Set.cpp. References ACE_TRACE, and nbits_. Referenced by sync(). 
 00124 {
00125 
00126  ACE_TRACE ("ACE_Handle_Set::count_bits");
00127 #if defined (ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT)
00128   register int rval = 0;
00129 
00130   // Count the number of enabled bits in <n>.  This algorithm is very
00131   // fast, i.e., O(enabled bits in n).
00132 
00133   for (register u_long m = n;
00134        m != 0;
00135        m &= m - 1)
00136     rval++;
00137 
00138   return rval;
00139 #else
00140    return (ACE_Handle_Set::nbits_[n & 0xff]
00141           + ACE_Handle_Set::nbits_[(n >> 8) & 0xff]
00142           + ACE_Handle_Set::nbits_[(n >> 16) & 0xff]
00143           + ACE_Handle_Set::nbits_[(n >> 24) & 0xff]);
00144 #endif /* ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT */
00145 }
 | 
| 
 | 
| Dump the state of an object. 
 Definition at line 40 of file Handle_Set.cpp. References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_TEXT, ACE_TRACE, is_set(), LM_DEBUG, and max_handle_. 
 00041 {
00042 #if defined (ACE_HAS_DUMP)
00043   ACE_TRACE ("ACE_Handle_Set::dump");
00044 
00045   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00046 
00047   ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nsize_ = %d"), this->size_));
00048   ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nmax_handle_ = %d"), this->max_handle_));
00049   ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n[ ")));
00050 
00051 #if defined (ACE_WIN32)
00052   for (size_t i = 0; i < (size_t) this->mask_.fd_count + 1; i++)
00053     ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" %x "), this->mask_.fd_array[i]));
00054 #else /* !ACE_WIN32 */
00055   for (ACE_HANDLE i = 0; i < this->max_handle_ + 1; i++)
00056     if (this->is_set (i))
00057       ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" %d "), i));
00058 #endif /* ACE_WIN32 */
00059 
00060   ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" ]\n")));
00061   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00062 #endif /* ACE_HAS_DUMP */
00063 }
 | 
| 
 | 
| Returns a pointer to the underlying . Returns 0 if there are no handle bits set ( == 0). Definition at line 178 of file Handle_Set.inl. References ACE_TRACE. Referenced by ACE::handle_ready(), and ACE::select(). 
 | 
| 
 | 
| 
Checks whether handle is enabled. No range checking is performed so handle must be less than  Definition at line 80 of file Handle_Set.inl. References ACE_TRACE. Referenced by ACE_Select_Reactor_Impl::bit_ops(), clr_bit(), ACE_Select_Reactor_Notify::dispatch_notifications(), dump(), ACE_TP_Reactor::get_notify_handle(), ACE::handle_timed_complete(), ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::is_suspended_i(), ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::resume_i(), set_bit(), ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::suspend_i(), and ACE_Select_Reactor_Handler_Repository::unbind(). 
 00081 {
00082   ACE_TRACE ("ACE_Handle_Set::is_set");
00083 #if defined (ACE_HAS_BIG_FD_SET)
00084   return FD_ISSET (handle,
00085                    &this->mask_)
00086     && this->size_ > 0;
00087 #elif defined (ACE_HAS_NONCONST_FD_ISSET)
00088   return FD_ISSET (handle,
00089                    const_cast<fd_set*> (&this->mask_));
00090 #else
00091   return FD_ISSET (handle,
00092                    &this->mask_);
00093 #endif /* ACE_HAS_BIG_FD_SET */
00094 }
 | 
| 
 | 
| Returns the number of the large bit. 
 Definition at line 71 of file Handle_Set.inl. References ACE_TRACE, and max_handle_. Referenced by ACE_Select_Reactor_Handler_Repository::unbind(). 
 00072 {
00073   ACE_TRACE ("ACE_Handle_Set::max_set");
00074   return this->max_handle_;
00075 }
 | 
| 
 | 
| Returns a count of the number of enabled bits. 
 Definition at line 152 of file Handle_Set.inl. References ACE_TRACE. Referenced by ACE_Process::close_dup_handles(), ACE_Process::close_passed_handles(), ACE_Process_Options::dup_handles(), and ACE_Process_Options::passed_handles(). 
 | 
| 
 | 
| Returns a pointer to the underlying . Returns 0 if there are no handle bits set ( == 0). Definition at line 165 of file Handle_Set.inl. References ACE_TRACE. 
 | 
| 
 | 
| Initialize the bitmask to all 0s and reset the associated fields. 
 Definition at line 29 of file Handle_Set.inl. References ACE_TRACE, max_handle_, and WORDSIZE. Referenced by ACE_Handle_Set(), ACE_TP_Reactor::clear_dispatch_mask(), ACE_Process::close_dup_handles(), ACE_Process::close_passed_handles(), ACE_Process_Options::dup_handles(), ACE_TP_Reactor::get_event_for_dispatching(), ACE_Process_Options::passed_handles(), ACE_SOCK_Dgram::recv(), ACE_SOCK_IO::recvv(), and ACE_SOCK_Dgram::send(). 
 00030 {
00031   ACE_TRACE ("ACE_Handle_Set::reset");
00032   this->max_handle_ =
00033     ACE_INVALID_HANDLE;
00034 #if defined (ACE_HAS_BIG_FD_SET)
00035   this->min_handle_ =
00036     NUM_WORDS * WORDSIZE;
00037 #endif /* ACE_HAS_BIG_FD_SET */
00038   this->size_ = 0;
00039   // #if !defined (ACE_HAS_BIG_FD_SET)      Why is this here?  -Steve Huston
00040   FD_ZERO (&this->mask_);
00041   // #endif /* ACE_HAS_BIG_FD_SET */
00042 }
 | 
| 
 | 
| 
Enables the handle. No range checking is performed so handle must be less than  Definition at line 99 of file Handle_Set.inl. References ACE_TRACE, is_set(), and max_handle_. Referenced by ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::check_handles(), ACE_Handle_Gobbler::consume_handles(), ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >::handle_input(), ACE::handle_ready(), ACE::handle_timed_accept(), ACE::handle_timed_complete(), ACE_Process_Options::pass_handle(), ACE_SOCK_Dgram::recv(), ACE_SOCK_Dgram_SC< STREAM >::recv(), ACE_SOCK_IO::recvv(), ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::resume_i(), ACE_OS::sema_wait(), ACE_SOCK_Dgram::send(), and ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::suspend_i(). 
 00100 {
00101   ACE_TRACE ("ACE_Handle_Set::set_bit");
00102   if ((handle != ACE_INVALID_HANDLE)
00103       && (!this->is_set (handle)))
00104     {
00105 #if defined (ACE_WIN32)
00106       FD_SET ((SOCKET) handle,
00107               &this->mask_);
00108       ++this->size_;
00109 #else /* ACE_WIN32 */
00110 #if defined (ACE_HAS_BIG_FD_SET)
00111       if (this->size_ == 0)
00112         FD_ZERO (&this->mask_);
00113 
00114       if (handle < this->min_handle_)
00115         this->min_handle_ = handle;
00116 #endif /* ACE_HAS_BIG_FD_SET */
00117 
00118       FD_SET (handle,
00119               &this->mask_);
00120       ++this->size_;
00121 
00122       if (handle > this->max_handle_)
00123         this->max_handle_ = handle;
00124 #endif /* ACE_WIN32 */
00125     }
00126 }
 | 
| 
 | 
| Resets the after a clear of the original . Definition at line 218 of file Handle_Set.cpp. References ACE_DIV_BY_WORDSIZE, ACE_MSB_MASK, ACE_MULT_BY_WORDSIZE, ACE_TRACE, max_handle_, and MAXSIZE. Referenced by clr_bit(), and sync(). 
 00219 {
00220   ACE_TRACE ("ACE_Handle_Set::set_max");
00221 #if !defined(ACE_WIN32)
00222   fd_mask * maskp = (fd_mask *)(this->mask_.fds_bits);
00223 
00224   if (this->size_ == 0)
00225     this->max_handle_ = ACE_INVALID_HANDLE;
00226   else
00227     {
00228       int i;
00229 
00230       for (i = ACE_DIV_BY_WORDSIZE (current_max - 1);
00231            maskp[i] == 0;
00232            i--)
00233         continue;
00234 #if defined (ACE_TANDEM_NSK_BIT_ORDER)
00235       // bits are in reverse order, MSB (sign bit) = bit 0.
00236       this->max_handle_ = ACE_MULT_BY_WORDSIZE (i);
00237       for (fd_mask val = maskp[i];
00238            (val & ACE_MSB_MASK) != 0;
00239            val = (val << 1))
00240         ++this->max_handle_;
00241 #elif 1 /* !defined(ACE_HAS_BIG_FD_SET) */
00242       this->max_handle_ = ACE_MULT_BY_WORDSIZE (i);
00243       for (fd_mask val = maskp[i];
00244            (val & ~1) != 0; // This obscure code is needed since "bit 0" is in location 1...
00245            val = (val >> 1) & ACE_MSB_MASK)
00246         ++this->max_handle_;
00247 #else
00248       register u_long val = this->mask_.fds_bits[i];
00249       this->max_handle_ = ACE_MULT_BY_WORDSIZE (i)
00250         + ACE_Handle_Set::bitpos(val & ~(val - 1));
00251 #endif /* 1 */
00252     }
00253 
00254   // Do some sanity checking...
00255   if (this->max_handle_ >= ACE_Handle_Set::MAXSIZE)
00256     this->max_handle_ = ACE_Handle_Set::MAXSIZE - 1;
00257 #else
00258   ACE_UNUSED_ARG (current_max);
00259 #endif /* !ACE_WIN32 */
00260 }
 | 
| 
 | 
| Rescan the underlying up to handle max to find the new (highest bit set) and (how many bits set) values. This is useful for evaluating the changes after the handle set has been manipulated in some way other than member functions; for example, after modifies the . Definition at line 197 of file Handle_Set.cpp. References ACE_DIV_BY_WORDSIZE, ACE_TRACE, count_bits(), and set_max(). Referenced by ACE_Handle_Set(), ACE_TP_Reactor::get_event_for_dispatching(), and ACE::select(). 
 00198 {
00199   ACE_TRACE ("ACE_Handle_Set::sync");
00200 #if !defined (ACE_WIN32)
00201   fd_mask *maskp = (fd_mask *)(this->mask_.fds_bits);
00202   this->size_ = 0;
00203 
00204   for (int i = ACE_DIV_BY_WORDSIZE (max - 1);
00205        i >= 0;
00206        i--)
00207     this->size_ += ACE_Handle_Set::count_bits (maskp[i]);
00208 
00209   this->set_max (max);
00210 #else
00211   ACE_UNUSED_ARG (max);
00212 #endif /* !ACE_WIN32 */
00213 }
 | 
| 
 | 
| 
 Definition at line 56 of file Handle_Set.h. | 
| 
 | 
| Declare the dynamic allocation hooks. 
 Definition at line 125 of file Handle_Set.h. | 
| 
 | 
| Bitmask. 
 Definition at line 140 of file Handle_Set.h. Referenced by ACE_Handle_Set_Iterator::ACE_Handle_Set_Iterator(), ACE_Handle_Set_Iterator::operator()(), and ACE_Handle_Set_Iterator::reset_state(). | 
| 
 | 
| Current max handle. 
 Definition at line 132 of file Handle_Set.h. Referenced by ACE_Handle_Set_Iterator::ACE_Handle_Set_Iterator(), clr_bit(), dump(), max_set(), ACE_Handle_Set_Iterator::operator()(), reset(), ACE_Handle_Set_Iterator::reset_state(), set_bit(), and set_max(). | 
| 
 | 
| Initial value: 
{
  0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
  1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
  1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
  2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
  1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
  2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
  2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
  3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
  1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
  2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
  2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
  3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
  2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
  3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
  3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
  4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8}
Definition at line 77 of file Handle_Set.cpp. Referenced by count_bits(). | 
| 
 | 
| Size of the set, i.e., a count of the number of enabled bits. 
 Definition at line 129 of file Handle_Set.h. | 
 1.3.6
 
1.3.6