poll_set.h
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2008, Willow Garage, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of Willow Garage, Inc. nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 #ifndef ROSCPP_POLL_SET_H
36 #define ROSCPP_POLL_SET_H
37 
38 #include <vector>
39 #include "io.h"
40 #include "common.h"
41 #include <boost/shared_ptr.hpp>
42 #include <boost/function.hpp>
43 #include <boost/thread/mutex.hpp>
44 
45 namespace ros
46 {
47 
48 class Transport;
50 
57 class ROSCPP_DECL PollSet
58 {
59 public:
60  PollSet();
61  ~PollSet();
62 
63  typedef boost::function<void(int)> SocketUpdateFunc;
73  bool addSocket(int sock, const SocketUpdateFunc& update_func, const TransportPtr& transport = TransportPtr());
80  bool delSocket(int sock);
81 
89  bool addEvents(int sock, int events);
97  bool delEvents(int sock, int events);
98 
111  void update(int poll_timeout);
112 
117  void signal();
118 
119 private:
123  void createNativePollset();
124 
128  void onLocalPipeEvents(int events);
129 
130  struct SocketInfo
131  {
132  TransportPtr transport_;
133  SocketUpdateFunc func_;
134  int fd_;
135  int events_;
136  };
137  typedef std::map<int, SocketInfo> M_SocketInfo;
138  M_SocketInfo socket_info_;
139  boost::mutex socket_info_mutex_;
141 
142  boost::mutex just_deleted_mutex_;
143  typedef std::vector<int> V_int;
145 
146  std::vector<socket_pollfd> ufds_;
147 
148  boost::mutex signal_mutex_;
149  signal_fd_t signal_pipe_[2];
150 
151  int epfd_;
152 };
153 
154 }
155 
156 #endif // ROSCPP_POLL_SET_H
boost::mutex signal_mutex_
Definition: poll_set.h:148
TransportPtr transport_
Definition: poll_set.h:132
int signal_fd_t
Definition: io.h:137
Manages a set of sockets being polled through the poll() function call.
Definition: poll_set.h:57
boost::shared_ptr< Transport > TransportPtr
Definition: connection.h:55
V_int just_deleted_
Definition: poll_set.h:144
M_SocketInfo socket_info_
Definition: poll_set.h:138
void update(const std::string &key, const XmlRpc::XmlRpcValue &v)
Definition: param.cpp:787
std::map< int, SocketInfo > M_SocketInfo
Definition: poll_set.h:137
bool sockets_changed_
Definition: poll_set.h:140
boost::function< void(int)> SocketUpdateFunc
Definition: poll_set.h:63
boost::mutex just_deleted_mutex_
Definition: poll_set.h:142
boost::mutex socket_info_mutex_
Definition: poll_set.h:139
std::vector< int > V_int
Definition: poll_set.h:143
SocketUpdateFunc func_
Definition: poll_set.h:133
std::vector< socket_pollfd > ufds_
Definition: poll_set.h:146


roscpp
Author(s): Morgan Quigley, Josh Faust, Brian Gerkey, Troy Straszheim
autogenerated on Fri Jun 8 2018 02:54:34