2 #include "ace/Log_Category.h"
4 #if defined (ACE_HAS_STRINGS)
5 # include "ace/os_include/os_strings.h"
6 #endif /* ACE_HAS_STRINGS */
8 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
10 /// Initialize the bitmask to all 0s and reset the associated fields.
12 ACE_Handle_Set::reset ()
14 ACE_TRACE ("ACE_Handle_Set::reset");
15 this->max_handle_ = ACE_INVALID_HANDLE;
16 #if defined (ACE_HAS_BIG_FD_SET)
17 this->min_handle_ = NUM_WORDS * WORDSIZE;
18 #endif /* ACE_HAS_BIG_FD_SET */
20 // #if !defined (ACE_HAS_BIG_FD_SET) Why is this here? -Steve Huston
21 FD_ZERO (&this->mask_);
22 // #endif /* ACE_HAS_BIG_FD_SET */
25 #if defined (ACE_HAS_BIG_FD_SET)
26 ACE_INLINE ACE_Handle_Set &
27 ACE_Handle_Set::operator = (const ACE_Handle_Set &rhs)
29 ACE_TRACE ("ACE_Handle_Set::operator =");
33 this->size_ = rhs.size_;
34 this->max_handle_ = rhs.max_handle_;
35 this->min_handle_ = rhs.min_handle_;
36 this->mask_ = rhs.mask_;
47 ACE_Handle_Set::ACE_Handle_Set (const ACE_Handle_Set &rhs)
49 ACE_TRACE ("ACE_Handle_Set::ACE_Handle_Set");
53 this->size_ = rhs.size_;
54 this->max_handle_ = rhs.max_handle_;
55 this->min_handle_ = rhs.min_handle_;
56 this->mask_ = rhs.mask_;
63 #endif /* ACE_HAS_BIG_FD_SET */
65 /// Returns the number of the large bit.
67 ACE_Handle_Set::max_set () const
69 ACE_TRACE ("ACE_Handle_Set::max_set");
70 return this->max_handle_;
73 /// Checks whether handle is enabled.
75 ACE_Handle_Set::is_set (ACE_HANDLE handle) const
77 ACE_TRACE ("ACE_Handle_Set::is_set");
79 fd_set *set = const_cast<fd_set*> (&this->mask_);
80 int ret = FD_ISSET (handle, set);
82 #if defined (ACE_HAS_BIG_FD_SET)
83 ret = ret && this->size_ > 0;
84 #elif defined (ACE_VXWORKS) && ACE_VXWORKS >= 0x690
90 /// Enables the handle.
92 ACE_Handle_Set::set_bit (ACE_HANDLE handle)
94 ACE_TRACE ("ACE_Handle_Set::set_bit");
95 if ((handle != ACE_INVALID_HANDLE)
96 && (!this->is_set (handle)))
98 #if defined (ACE_HANDLE_SET_USES_FD_ARRAY)
99 FD_SET ((SOCKET) handle,
102 #else /* ACE_HANDLE_SET_USES_FD_ARRAY */
103 #if defined (ACE_HAS_BIG_FD_SET)
104 if (this->size_ == 0)
105 FD_ZERO (&this->mask_);
107 if (handle < this->min_handle_)
108 this->min_handle_ = handle;
109 #endif /* ACE_HAS_BIG_FD_SET */
115 if (handle > this->max_handle_)
116 this->max_handle_ = handle;
117 #endif /* ACE_HANDLE_SET_USES_FD_ARRAY */
121 /// Disables the handle.
123 ACE_Handle_Set::clr_bit (ACE_HANDLE handle)
125 ACE_TRACE ("ACE_Handle_Set::clr_bit");
127 if ((handle != ACE_INVALID_HANDLE) &&
128 (this->is_set (handle)))
130 FD_CLR ((ACE_SOCKET) handle,
134 #if !defined (ACE_HANDLE_SET_USES_FD_ARRAY)
135 if (handle == this->max_handle_)
136 this->set_max (this->max_handle_);
137 #endif /* !ACE_HANDLE_SET_USES_FD_ARRAY */
141 /// Returns a count of the number of enabled bits.
143 ACE_Handle_Set::num_set () const
145 ACE_TRACE ("ACE_Handle_Set::num_set");
146 #if defined (ACE_HANDLE_SET_USES_FD_ARRAY)
147 return this->mask_.fd_count;
148 #else /* !ACE_HANDLE_SET_USES_FD_ARRAY */
150 #endif /* ACE_HANDLE_SET_USES_FD_ARRAY */
153 /// Returns a pointer to the underlying fd_set.
155 ACE_Handle_Set::operator fd_set *()
157 ACE_TRACE ("ACE_Handle_Set::operator fd_set *");
160 return (fd_set *) &this->mask_;
165 /// Returns a pointer to the underlying fd_set.
167 ACE_Handle_Set::fdset ()
169 ACE_TRACE ("ACE_Handle_Set::fdset");
172 return (fd_set *) &this->mask_;
177 ACE_END_VERSIONED_NAMESPACE_DECL