File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed
Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -163,13 +163,18 @@ The other purpose of the rxros::spin function is to dispatch messages from ROS t
163163Failure to omit the rxros::spin function will cause the program to terminate immediately and observables based on ROS topics
164164will not emit any events.
165165
166+ rxros::spin will per default use one thread for dispatching messages. For most nodes this will be sufficient.
167+ In special cases where a node uses many topics it may be necessary to use more threads for dispatching messages.
168+ This can be achieved by specifying the number of threads the rxros::spin function should use.
169+ A special case is rxros::spin(0) which will allocate a thread for each CPU core.
170+
166171The Example below shows a minimal RxROS program that creates a ROS node named “my_node”.
167172The program will due to rxros: spin () continue to run until it is either shutdown or terminated.
168173
169174### Syntax
170175
171176``` cpp
172- void rxros::spin ();
177+ void rxros::spin (uint32_t thread_count = 1 );
173178```
174179
175180### Example
Original file line number Diff line number Diff line change @@ -48,8 +48,8 @@ namespace rxros
4848 ros::init (argc, argv, name);
4949 }
5050
51- static void spin () {
52- ros::MultiThreadedSpinner spinner (0 ); // Use a spinner for each available CPU core
51+ static void spin (uint32_t thread_count = 1 ) { // Use per default 1 thread for spinning
52+ ros::MultiThreadedSpinner spinner (thread_count);
5353 spinner.spin ();
5454 }
5555
You can’t perform that action at this time.
0 commit comments