asynchronous IO in roscpp

asked 2016-09-12 19:26:54 -0600

sunking gravatar image

updated 2016-09-12 19:53:20 -0600

I am trying to get my head around how asynchronous IO is handled in ROS. Taking reading for example, I see when the poll manager starts it spins up a boost thread to run ThreadFunc in which the sockets are polled to see if they have any data. However, when I browse the code for actually reading (eg from OnMessageLength) everything looks synchronous. PublisherLink::onMessageLength --calls--> Connection:read --calls-> Connection::readTransport --calls-> TransportTCP:read --calls-> ::recv. So, I am having a hard time seeing how and where these two connect. I am speculating that all of this reading part takes place in the same thread that ThreadFunc is running in and it sleeps if ::recv (::send in the case of publishing) has no data, control is passed to the main thread in which subscribe and ros::spin are running (which is responsible for processing the callback queue/publishing queues), and its woken up when there's data available and after the data is read, control is transferred to the onMessage callback which again suspends until there is data, but it would be nice if someone could confirm and or explain this a bit! Also, how many threads are there typically running ( assuming a single treaded processing of the callback queue)?


edit retag flag offensive close merge delete