ROS 2 rclcpp + rcl - rolling  rolling-e7363f10
ROS 2 C++ Client Library with ROS Client Library
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
rclcpp::executors::cbg_executor::CBGScheduler Class Referenceabstract
Inheritance diagram for rclcpp::executors::cbg_executor::CBGScheduler:
Inheritance graph
[legend]
Collaboration diagram for rclcpp::executors::cbg_executor::CBGScheduler:
Collaboration graph
[legend]

Classes

struct  CallbackEventType
 
struct  CallbackGroupHandle
 
struct  ExecutableEntity
 
struct  ExecutableEntityWithInfo
 
struct  WaitableWithEventType
 

Public Member Functions

 CBGScheduler (std::function< void()> sync_function)
 
 CBGScheduler (const CBGScheduler &)=delete
 
 CBGScheduler (CBGScheduler &&)=delete
 
CBGScheduler & operator= (const CBGScheduler &)=delete
 
CBGScheduler & operator= (CBGScheduler &&)=delete
 
CallbackGroupHandle * add_callback_group (const rclcpp::CallbackGroup::SharedPtr &callback_group)
 
void remove_callback_group (const CallbackGroupHandle *callback_handle)
 
void callback_group_ready (CallbackGroupHandle *handle, bool callback_group_was_idle)
 
ExecutableEntityWithInfo get_next_ready_entity ()
 
ExecutableEntityWithInfo get_next_ready_entity (GlobalEventIdProvider::MonotonicId max_id)
 
virtual ExecutableEntityWithInfo get_next_ready_entity_intern ()=0
 
virtual ExecutableEntityWithInfo get_next_ready_entity_intern (GlobalEventIdProvider::MonotonicId max_id)=0
 
void trigger_sync ()
 
void mark_entity_as_executed (const ExecutableEntity &e)
 
void suppress_thread_wakeup ()
 
void unblock_one_worker_thread ()
 
void block_worker_thread (Worker *worker)
 
void block_worker_thread_for (Worker *worker, std::chrono::nanoseconds timeout)
 
void release_all_worker_threads ()
 

Protected Member Functions

virtual std::unique_ptr< CallbackGroupHandle > get_handle_for_callback_group (const rclcpp::CallbackGroup::SharedPtr &callback_group)=0
 
bool prepare_and_enqueue_worker (Worker *worker)
 

Protected Attributes

std::function< void()> sync_function
 
bool needs_sync = false
 
std::mutex ready_callback_groups_mutex
 
std::deque< CallbackGroupHandle * > ready_callback_groups
 
bool worker_checking_for_work = false
 
WorkerQueue worker_queue
 
std::list< std::unique_ptr< CallbackGroupHandle > > callback_groups
 

Detailed Description

Definition at line 163 of file scheduler.hpp.

Constructor & Destructor Documentation

◆ CBGScheduler()

rclcpp::executors::cbg_executor::CBGScheduler::CBGScheduler ( std::function< void()>  sync_function)
inlineexplicit
Parameters
sync_functionA special purpose sync function, that shall be executed with high priority if triggered by trigger_sync();

Definition at line 326 of file scheduler.hpp.

Member Function Documentation

◆ block_worker_thread()

void rclcpp::executors::cbg_executor::CBGScheduler::block_worker_thread ( Worker *  worker)
inline

Blocks the worker until work is available. Checking for work and registering as blocked happens atomically under the same lock that callback_group_ready / trigger_sync use to add work, so no wakeup can be lost in between. Returns immediately if work showed up, or if the worker queue was released.

Definition at line 508 of file scheduler.hpp.

References prepare_and_enqueue_worker().

Here is the call graph for this function:

◆ callback_group_ready()

void rclcpp::executors::cbg_executor::CBGScheduler::callback_group_ready ( CallbackGroupHandle *  handle,
bool  callback_group_was_idle 
)
inline

Will be called, by CallbackGroupHandle if any entity in the cb group is ready for execution and the cb group was idle before

Parameters
callback_group_was_idleIs false, if no entity of the callback group was executed, before this call was made. This means we need to wakeup a a new thread.

Definition at line 367 of file scheduler.hpp.

References unblock_one_worker_thread().

Referenced by rclcpp::executors::cbg_executor::CBGScheduler::CallbackGroupHandle::add_ready_entity(), and rclcpp::executors::cbg_executor::CBGScheduler::CallbackGroupHandle::mark_as_executed().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_next_ready_entity()

ExecutableEntityWithInfo rclcpp::executors::cbg_executor::CBGScheduler::get_next_ready_entity ( )
inline

Returns the next ready entity that shall be executed. If a entity is removed here, the scheduler may assume that it will be executed, and that the function mark_entity_as_executed will be called afterwards.

Definition at line 395 of file scheduler.hpp.

References get_next_ready_entity_intern().

Here is the call graph for this function:

◆ get_next_ready_entity_intern()

virtual ExecutableEntityWithInfo rclcpp::executors::cbg_executor::CBGScheduler::get_next_ready_entity_intern ( )
pure virtual

Will be called while holding the ready_callback_groups_mutex lock

Referenced by get_next_ready_entity().

Here is the caller graph for this function:

◆ mark_entity_as_executed()

void rclcpp::executors::cbg_executor::CBGScheduler::mark_entity_as_executed ( const ExecutableEntity &  e)
inline

Must be called, after a entity was executed. This function will normally be used, to mark the associated callback group as ready again.

Definition at line 461 of file scheduler.hpp.

References rclcpp::executors::cbg_executor::CBGScheduler::CallbackGroupHandle::mark_as_executed().

Here is the call graph for this function:

◆ prepare_and_enqueue_worker()

bool rclcpp::executors::cbg_executor::CBGScheduler::prepare_and_enqueue_worker ( Worker *  worker)
inlineprotected

Returns true if the worker was enqueued and shall block. Returns false if there is work pending or the queue was released.

Definition at line 548 of file scheduler.hpp.

References rclcpp::executors::cbg_executor::WorkerQueue::push_blocked_worker_thread().

Referenced by block_worker_thread().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ suppress_thread_wakeup()

void rclcpp::executors::cbg_executor::CBGScheduler::suppress_thread_wakeup ( )
inline

Suppresses the next thread wakeup. This is useful when we know that a thread is about to check for work anyway. In this case it would be harmful to wake another thread for nothing

Definition at line 473 of file scheduler.hpp.

◆ trigger_sync()

void rclcpp::executors::cbg_executor::CBGScheduler::trigger_sync ( )
inline

If this function was triggered, a worker thread must be woken up, and the next call to get_next_ready_entity must return a ExecutableEntityWithInfo with the sync function in it.Or reworded if this function is triggered the sync function will be executed as the next exent by the executor.

Definition at line 441 of file scheduler.hpp.

References unblock_one_worker_thread().

Here is the call graph for this function:

◆ unblock_one_worker_thread()

void rclcpp::executors::cbg_executor::CBGScheduler::unblock_one_worker_thread ( )
inline

Wakes up one blocked worker thread, unless a worker is already on its way to get_next_ready_entity(). The flag is only set if a worker was actually woken, otherwise no one would ever clear it.

Definition at line 484 of file scheduler.hpp.

References rclcpp::executors::cbg_executor::WorkerQueue::pop_blocked_worker_thread(), and rclcpp::executors::cbg_executor::Worker::unblock().

Referenced by callback_group_ready(), and trigger_sync().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: