Is it possible to avoid busy-waiting in a spinner? [closed]
I've read the Callbacks and Spinning page, and have written the following spinner:
void SteeringCtrlr::callCallbacks()
{
static const double timeout = 0.01;
while (node_->ok())
cb_queue_.callAvailable(ros::WallDuration(timeout));
}
If there are no callbacks in the queue, the "while" loop will busy-wait, using a lot of CPU time. I could not find a CallbackQueue equivalent of select(). Is it possible to implement such a thing? For example, is it possible to call select() on the sockets over which topic messages and service calls are received (if sockets are used for that purpose). I can reduce the frequency with which callAvailable() is called by creating a ros::Rate object and calling sleep() on it, but I'd rather avoid busy waiting at all if possible.