One Thread Per Subscriber
I'm using roscpp, and I am programmatically creating a bunch of subscriber callbacks (using ShapeShifter
). Each callback is not computationally expensive, but I'm measuring the difference between the published time in the header, and the received time. As such, the first line of my callback defines the received time.
So having a single threaded model isn't great, because one subscriber callback will block another callback, and increase its lag time.
Ideally I'd like to create one thread per subscriber. I can't use a custom callback queue, because these are not called by ros::spin
.
So what is the most idiomatic way to have each subscriber run on its own thread?