#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 ACE_FD_SET_TYPE &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 .
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 144 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. is a based on the platform's native type used for masks passed to . Definition at line 104 of file Handle_Set.cpp. References ACE_FD_SET_TYPE, 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 . No range checking is performed so must be less than . Definition at line 128 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().
00129 { 00130 ACE_TRACE ("ACE_Handle_Set::clr_bit"); 00131 00132 if ((handle != ACE_INVALID_HANDLE) && 00133 (this->is_set (handle))) 00134 { 00135 FD_CLR ((ACE_SOCKET) handle, 00136 &this->mask_); 00137 --this->size_; 00138 00139 #if !defined (ACE_WIN32) 00140 if (handle == this->max_handle_) 00141 this->set_max (this->max_handle_); 00142 #endif /* !ACE_WIN32 */ 00143 } 00144 } |
|
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_LIB_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_LIB_TEXT ("\nsize_ = %d"), this->size_)); 00048 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nmax_handle_ = %d"), this->max_handle_)); 00049 ACE_DEBUG ((LM_DEBUG, ACE_LIB_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_LIB_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_LIB_TEXT (" %d "), i)); 00058 #endif /* ACE_WIN32 */ 00059 00060 ACE_DEBUG ((LM_DEBUG, ACE_LIB_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 175 of file Handle_Set.inl. References ACE_TRACE. Referenced by ACE::handle_ready(), and ACE::select().
|
|
Checks whether is enabled. No range checking is performed so 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_FlReactor::fl_io_proc(), ACE_TP_Reactor::get_notify_handle(), ACE::handle_timed_complete(), ACE_XtReactor::InputCallbackProc(), ACE_TkReactor::InputCallbackProc(), 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().
|
|
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 149 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 162 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_WIN32_Asynch_Connect::cancel_uncompleted(), ACE_POSIX_Asynch_Connect::cancel_uncompleted(), 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(), ACE_QtReactor::reopen_notification_pipe(), 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 } |
|
|
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 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(), ACE::select(), ACE_XtReactor::wait_for_multiple_events(), ACE_TkReactor::wait_for_multiple_events(), ACE_QtReactor::wait_for_multiple_events(), and ACE_FlReactor::wait_for_multiple_events().
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 127 of file Handle_Set.h. |
|
Bitmask.
Definition at line 142 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 134 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 131 of file Handle_Set.h. |