Comments (3)
This relates to the upcoming discussion about the rcl API: how should we define the "spin" functions in Executor?
spin
: Blocking call, do work indefinitely as it comes in.
spin_once
: Do one "cycle" of work, with optional timeout. In a single-threaded executor, this means executing the first available executable. In a multi-threaded executor, does this mean executing exactly one executable, or does it mean executing one executable per thread? Does blocking mean that all threads block until they have work to do, or
spin_some
: Do all the work that is immediately available to the executor. This is probably the most ill-defined of the spin functions. The current single-threaded implementation is:
- Check if there is available work (non-blocking)
- Do the available work.
- Repeat until there is no more available work.
A few ideas for spin_some
for MultiThreadedExecutor
:
- Atomically check all of the work that is immediately available without blocking. Then, assign the executables to each available thread. If # of executables is less than # of threads, some threads might not do any work. If # of executables is greater than # of threads, each thread receives a fair amount of executables and executes them concurrently with the other threads.
This does not allow for new work to come in while work is being done, so it is not consistent with the single-threaded implementation. - Naively launch N threads (where N is the hardware concurrency) where each thread runs the single-threaded
spin_some
. Theget_next_executable
call is protected with a mutex, theexecute_any_executable
call is not.
The problem with this implementation is if new work comes in after threads have joined, then the new work cannot be assigned to these joined threads.
Each spin
function should have a spin_node
equivalent, and vice versa.
The MultiThreadedExecutor
probably should be modified to have a thread pool rather than spawning and joining threads at the beginning and end of each spin
call.
Also, it needs a test.
from rclcpp.
there should also be multi-threaded implementations of spin_once
and `spin_until_future_complete...
I'm pulling this out of the backlog because of my current work on abstracting synchronization in rclcpp.
from rclcpp.
This was done ages ago, so closing this out.
from rclcpp.
Related Issues (20)
- Canceling an action synchronously HOT 2
- `spin_some` easily deadlocks action clients HOT 3
- :farmer: Flaky test `test_executors_timer_cancel_behavior` HOT 5
- Timer in MultiThreadedExecutor crashes HOT 16
- Support simulation clock in `TimersManager` / `EventExecutor` HOT 1
- New do_intra_process_publish compiler warning after upgrading rolling to Ubuntu 24.04 HOT 9
- max_duration not respected in spin_some for StaticSingleThreadedExecutor and EventsExecutor HOT 4
- StaticSingleThreadedExecutor uses spin_once in spin HOT 1
- :farmer: `test_lifecycle_service_client` failing consisntent in CycloneDDS HOT 1
- Bug in Executor::get_next_ready_executable ? HOT 3
- TypeAdapted publishing doesn't use provided allocator HOT 3
- TimersManager doesn't follow ROS time HOT 2
- rclcpp_action: Provide enum class return ClientGoalHandle::get_status
- Callback works on Galactic but fails on Rolling - handle_message is not implemented for GenericSubscription HOT 1
- Clang warning: ordered comparison of function pointers (Rolling) HOT 1
- `-fanalyzer` warning: possible null dereference when using TypeAdapters HOT 4
- leak due to std::shared_ptr circular reference between Context and GuardCondition HOT 3
- :farmer: `rclcpp.test_executors` failing in Rolling and Jazzy CycloneDDS HOT 2
- rclcpp::Time(int64_t nanoseconds, ...) should check for negative time
- Regression : Executor::spin_some_impl is active waiting HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rclcpp.