Git Product home page Git Product logo

Comments (3)

jacquelinekay avatar jacquelinekay commented on July 18, 2024

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:

  1. Check if there is available work (non-blocking)
  2. Do the available work.
  3. 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. The get_next_executable call is protected with a mutex, the execute_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.

jacquelinekay avatar jacquelinekay commented on July 18, 2024

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.

clalancette avatar clalancette commented on July 18, 2024

This was done ages ago, so closing this out.

from rclcpp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.