ros::PollSet Class Reference

Manages a set of sockets being polled through the poll() function call. More...

#include <poll_set.h>

List of all members.

Classes

struct  SocketInfo

Public Types

typedef boost::function< void(int)> SocketUpdateFunc

Public Member Functions

bool addEvents (int sock, int events)
 Add events to be polled on a socket.
bool addSocket (int sock, const SocketUpdateFunc &update_func, const TransportPtr &transport=TransportPtr())
 Add a socket.
bool delEvents (int sock, int events)
 Delete events to be polled on a socket.
bool delSocket (int sock)
 Delete a socket.
 PollSet ()
void signal ()
 Signal our poll() call to finish if it's blocked waiting (see the poll_timeout option for update()).
void update (int poll_timeout)
 Process all socket events.
 ~PollSet ()

Private Types

typedef std::map< int, SocketInfoM_SocketInfo
typedef std::vector< int > V_int

Private Member Functions

void createNativePollset ()
 Creates the native pollset for our sockets, if any have changed.
void onLocalPipeEvents (int events)
 Called when events have been triggered on our signal pipe.

Private Attributes

V_int just_deleted_
boost::mutex just_deleted_mutex_
boost::mutex signal_mutex_
int signal_pipe_ [2]
M_SocketInfo socket_info_
boost::mutex socket_info_mutex_
bool sockets_changed_
std::vector< struct pollfd > ufds_

Detailed Description

Manages a set of sockets being polled through the poll() function call.

PollSet provides thread-safe ways of adding and deleting sockets, as well as adding and deleting events.

Definition at line 58 of file poll_set.h.


Member Typedef Documentation

typedef std::map<int, SocketInfo> ros::PollSet::M_SocketInfo [private]

Definition at line 138 of file poll_set.h.

typedef boost::function<void(int)> ros::PollSet::SocketUpdateFunc

Definition at line 64 of file poll_set.h.

typedef std::vector<int> ros::PollSet::V_int [private]

Definition at line 144 of file poll_set.h.


Constructor & Destructor Documentation

ros::PollSet::PollSet (  ) 

Definition at line 52 of file poll_set.cpp.

ros::PollSet::~PollSet (  ) 

Definition at line 79 of file poll_set.cpp.


Member Function Documentation

bool ros::PollSet::addEvents ( int  sock,
int  events 
)

Add events to be polled on a socket.

addEvents() may be called from any thread.

Parameters:
sock The socket to add events to
events The events to add

Definition at line 141 of file poll_set.cpp.

bool ros::PollSet::addSocket ( int  sock,
const SocketUpdateFunc update_func,
const TransportPtr transport = TransportPtr() 
)

Add a socket.

addSocket() may be called from any thread.

Parameters:
sock The socket to add
update_func The function to call when a socket has events
transport The (optional) transport associated with this socket. Mainly used to prevent the transport from being deleted while we're calling the update function

Definition at line 85 of file poll_set.cpp.

void ros::PollSet::createNativePollset (  )  [private]

Creates the native pollset for our sockets, if any have changed.

Definition at line 279 of file poll_set.cpp.

bool ros::PollSet::delEvents ( int  sock,
int  events 
)

Delete events to be polled on a socket.

delEvents() may be called from any thread.

Parameters:
sock The socket to delete events from
events The events to delete

Definition at line 160 of file poll_set.cpp.

bool ros::PollSet::delSocket ( int  sock  ) 

Delete a socket.

delSocket() may be called from any thread.

Parameters:
sock The socket to delete

Definition at line 111 of file poll_set.cpp.

void ros::PollSet::onLocalPipeEvents ( int  events  )  [private]

Called when events have been triggered on our signal pipe.

Definition at line 302 of file poll_set.cpp.

void ros::PollSet::signal (  ) 

Signal our poll() call to finish if it's blocked waiting (see the poll_timeout option for update()).

Definition at line 180 of file poll_set.cpp.

void ros::PollSet::update ( int  poll_timeout  ) 

Process all socket events.

This function will actually call poll() on the available sockets, and allow them to do their processing.

update() may only be called from one thread at a time

Parameters:
poll_timeout The time, in milliseconds, for the poll() call to timeout after if there are no events. Note that this does not provide an upper bound for the entire function, just the call to poll()

Definition at line 195 of file poll_set.cpp.


Member Data Documentation

Definition at line 145 of file poll_set.h.

boost::mutex ros::PollSet::just_deleted_mutex_ [private]

Definition at line 143 of file poll_set.h.

boost::mutex ros::PollSet::signal_mutex_ [private]

Definition at line 149 of file poll_set.h.

int ros::PollSet::signal_pipe_[2] [private]

Definition at line 150 of file poll_set.h.

Definition at line 139 of file poll_set.h.

boost::mutex ros::PollSet::socket_info_mutex_ [private]

Definition at line 140 of file poll_set.h.

Definition at line 141 of file poll_set.h.

std::vector<struct pollfd> ros::PollSet::ufds_ [private]

Definition at line 147 of file poll_set.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


roscpp
Author(s): Morgan Quigley mquigley@cs.stanford.edu, Josh Faust jfaust@willowgarage.com, Brian Gerkey gerkey@willowgarage.com
autogenerated on Fri Jan 11 10:08:41 2013