42 #include <boost/bind.hpp> 72 info.
func_ = update_func;
77 bool b =
socket_info_.insert(std::make_pair(fd, info)).second;
120 ROSCPP_LOG_DEBUG(
"PollSet: Tried to delete fd [%d] which is not being tracked", fd);
134 ROSCPP_LOG_DEBUG(
"PollSet: Tried to add events [%d] to fd [%d] which does not exist in this pollset", events, sock);
138 it->second.events_ |= events;
155 it->second.events_ &= ~events;
159 ROSCPP_LOG_DEBUG(
"PollSet: Tried to delete events [%d] to fd [%d] which does not exist in this pollset", events, sock);
175 if (lock.owns_lock())
198 for (std::vector<socket_pollfd>::iterator it = ofds->begin() ; it != ofds->end(); ++it)
201 int revents = it->revents;
230 && ((events & revents)
231 || (revents & POLLERR)
232 || (revents & POLLHUP)
233 || (revents & POLLNVAL)))
236 if (revents & (POLLNVAL|POLLERR|POLLHUP))
252 func(revents & (events|POLLERR|POLLHUP|POLLNVAL));
276 for (
int i = 0; sock_it != sock_end; ++sock_it, ++i)
ROSCPP_DECL void del_socket_from_watcher(int epfd, int fd)
ROSCPP_DECL int create_socket_watcher()
boost::mutex signal_mutex_
bool addEvents(int sock, int events)
Add events to be polled on a socket.
void onLocalPipeEvents(int events)
Called when events have been triggered on our signal pipe.
M_SocketInfo socket_info_
ROSCPP_DECL void close_socket_watcher(int fd)
signal_fd_t signal_pipe_[2]
ROSCPP_DECL const char * last_socket_error_string()
ssize_t write_signal(const signal_fd_t &signal, const void *buffer, const size_t &nbyte)
#define ROSCPP_LOG_DEBUG(...)
void update(int poll_timeout)
Process all socket events.
void signal()
Signal our poll() call to finish if it's blocked waiting (see the poll_timeout option for update())...
ROSCPP_DECL pollfd_vector_ptr poll_sockets(int epfd, socket_pollfd *fds, nfds_t nfds, int timeout)
A cross platform polling function for sockets.
boost::function< void(int)> SocketUpdateFunc
bool delEvents(int sock, int events)
Delete events to be polled on a socket.
boost::mutex just_deleted_mutex_
bool delSocket(int sock)
Delete a socket.
ssize_t read_signal(const signal_fd_t &signal, void *buffer, const size_t &nbyte)
struct pollfd socket_pollfd
ROSCPP_DECL void set_events_on_socket(int epfd, int fd, int events)
void close_signal_pair(signal_fd_t signal_pair[2])
ROSCPP_DECL int create_signal_pair(signal_fd_t signal_pair[2])
boost::mutex socket_info_mutex_
void createNativePollset()
Creates the native pollset for our sockets, if any have changed.
#define ROS_ERROR_STREAM(args)
bool addSocket(int sock, const SocketUpdateFunc &update_func, const TransportPtr &transport=TransportPtr())
Add a socket.
ROSCPP_DECL void add_socket_to_watcher(int epfd, int fd)
std::vector< socket_pollfd > ufds_