Open henrik7264 opened 5 years ago
Would it be an idea to leave spinning to the user? That is how roscpp
also works, and unless rxros
needs to do something special while spinning, might be a good approach to copy: it leaves the decision to the user, which both removes the problem from rxros
and gives users more control.
If they don't want/need control, they could just do whatever they'd do normally with roscpp
(probably copy-paste the ros::spin()
line or use an ros::AsyncSpinner
). If they do want control, they'd probably have a bit more insight into how things work and should be able to make an informed decision.
The idea with the rxros::spin() is to provide a simple wrapper around the ros::MultiThreadedSpinner and to give some consistency to the language. The programmer should to the extend possible be keept into rxros mindset. This is its main function. If more control is needed the programmer can always fallback to ROS core functionality.
The rxros::spin() function is based on the ros::MultiThreadedSpinner. It is configured to use a spinner/thread for each available CPU core. This means that on a machine with 4 cores each an every node will take up at least 4 threads whether they the are needed or not.
Proposed solution: The ros::spin() should per default only use one thread for spinning and take an argument that will allow the programmer to specify the needed number of spinners/threads.