3 #ifndef __ZMQ_SOCKET_POLLING_UTIL_HPP_INCLUDED__
4 #define __ZMQ_SOCKET_POLLING_UTIL_HPP_INCLUDED__
9 #if defined ZMQ_HAVE_WINDOWS
12 #include <sys/select.h>
17 #include "platform.hpp"
28 _buf =
new (std::nothrow)
T[nitems_];
60 }
else if (nitems_ >
S) {
61 _dynamic_buf =
new (std::nothrow) std::vector<T> (nitems_);
85 #if defined ZMQ_POLL_BASED_ON_POLL
86 typedef int timeout_t;
89 compute_timeout (
bool first_pass_,
long timeout_, uint64_t now_, uint64_t end_);
91 #if (!defined ZMQ_POLL_BASED_ON_POLL && defined ZMQ_POLL_BASED_ON_SELECT) \
92 || defined ZMQ_HAVE_PPOLL
93 #if defined ZMQ_HAVE_WINDOWS
94 inline size_t valid_pollset_bytes (
const fd_set &pollset_)
100 return reinterpret_cast<const char *
> (
101 &pollset_.fd_array[pollset_.fd_count])
102 -
reinterpret_cast<const char *
> (&pollset_);
105 inline size_t valid_pollset_bytes (
const fd_set & )
107 return sizeof (fd_set);
112 #if defined ZMQ_HAVE_WINDOWS
119 class optimized_fd_set_t
122 explicit optimized_fd_set_t (
size_t nevents_) : _fd_set (1 + nevents_) {}
124 fd_set *
get () {
return reinterpret_cast<fd_set *
> (&_fd_set[0]); }
127 fast_vector_t<SOCKET, 1 + ZMQ_POLLITEMS_DFLT> _fd_set;
130 class resizable_optimized_fd_set_t
133 void resize (
size_t nevents_) { _fd_set.resize (1 + nevents_); }
135 fd_set *
get () {
return reinterpret_cast<fd_set *
> (&_fd_set[0]); }
138 resizable_fast_vector_t<SOCKET, 1 + ZMQ_POLLITEMS_DFLT> _fd_set;
141 class optimized_fd_set_t
144 explicit optimized_fd_set_t (
size_t ) {}
146 fd_set *
get () {
return &_fd_set; }
152 class resizable_optimized_fd_set_t :
public optimized_fd_set_t
155 resizable_optimized_fd_set_t () : optimized_fd_set_t (0) {}
157 void resize (
size_t ) {}