00001
00002
00003
00004
00005 #include "ace/Log_Msg.h"
00006
00007
00008
00009 #include "ace/os_include/os_string.h"
00010
00011
00012 #include "ace/os_include/os_strings.h"
00013
00014
00015 #if defined (ACE_HAS_BSTRING)
00016 # include <bstring.h>
00017 #endif
00018
00019
00020 #if defined (ACE_HAS_STRINGS)
00021 # include "ace/os_include/os_strings.h"
00022 #endif
00023
00024 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00025
00026
00027
00028 ACE_INLINE void
00029 ACE_Handle_Set::reset (void)
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
00038 this->size_ = 0;
00039
00040 FD_ZERO (&this->mask_);
00041
00042 }
00043
00044 #if defined (ACE_HAS_BIG_FD_SET)
00045 ACE_INLINE ACE_Handle_Set &
00046 ACE_Handle_Set::operator = (const ACE_Handle_Set &rhs)
00047 {
00048 ACE_TRACE ("ACE_Handle_Set::operator =");
00049
00050 if (rhs.size_ > 0)
00051 {
00052 this->size_ =
00053 rhs.size_;
00054 this->max_handle_ =
00055 rhs.max_handle_;
00056 this->min_handle_ =
00057 rhs.min_handle_;
00058 this->mask_ =
00059 rhs.mask_;
00060 }
00061 else
00062 this->reset ();
00063
00064 return *this;
00065 }
00066 #endif
00067
00068
00069
00070 ACE_INLINE ACE_HANDLE
00071 ACE_Handle_Set::max_set (void) const
00072 {
00073 ACE_TRACE ("ACE_Handle_Set::max_set");
00074 return this->max_handle_;
00075 }
00076
00077
00078
00079 ACE_INLINE int
00080 ACE_Handle_Set::is_set (ACE_HANDLE handle) const
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 #else
00088 return FD_ISSET (handle,
00089 &this->mask_);
00090 #endif
00091 }
00092
00093
00094
00095 ACE_INLINE void
00096 ACE_Handle_Set::set_bit (ACE_HANDLE handle)
00097 {
00098 ACE_TRACE ("ACE_Handle_Set::set_bit");
00099 if ((handle != ACE_INVALID_HANDLE)
00100 && (!this->is_set (handle)))
00101 {
00102 #if defined (ACE_WIN32)
00103 FD_SET ((SOCKET) handle,
00104 &this->mask_);
00105 ++this->size_;
00106 #else
00107 #if defined (ACE_HAS_BIG_FD_SET)
00108 if (this->size_ == 0)
00109 FD_ZERO (&this->mask_);
00110
00111 if (handle < this->min_handle_)
00112 this->min_handle_ = handle;
00113 #endif
00114
00115 FD_SET (handle,
00116 &this->mask_);
00117 ++this->size_;
00118
00119 if (handle > this->max_handle_)
00120 this->max_handle_ = handle;
00121 #endif
00122 }
00123 }
00124
00125
00126
00127 ACE_INLINE void
00128 ACE_Handle_Set::clr_bit (ACE_HANDLE handle)
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
00143 }
00144 }
00145
00146
00147
00148 ACE_INLINE int
00149 ACE_Handle_Set::num_set (void) const
00150 {
00151 ACE_TRACE ("ACE_Handle_Set::num_set");
00152 #if defined (ACE_WIN32)
00153 return this->mask_.fd_count;
00154 #else
00155 return this->size_;
00156 #endif
00157 }
00158
00159
00160
00161 ACE_INLINE
00162 ACE_Handle_Set::operator fd_set *()
00163 {
00164 ACE_TRACE ("ACE_Handle_Set::operator fd_set *");
00165
00166 if (this->size_ > 0)
00167 return (fd_set *) &this->mask_;
00168 else
00169 return (fd_set *) 0;
00170 }
00171
00172
00173
00174 ACE_INLINE fd_set *
00175 ACE_Handle_Set::fdset (void)
00176 {
00177 ACE_TRACE ("ACE_Handle_Set::fdset");
00178
00179 if (this->size_ > 0)
00180 return (fd_set *) &this->mask_;
00181 else
00182 return (fd_set *) 0;
00183 }
00184
00185 ACE_INLINE
00186 ACE_Handle_Set_Iterator::~ACE_Handle_Set_Iterator (void)
00187 {
00188 }
00189
00190 ACE_END_VERSIONED_NAMESPACE_DECL