![]() |
ros2_control - jazzy
|
Class to handle asynchronous function calls. AsyncFunctionHandler is a class that allows the user to have a asynchronous call to the parsed method and be able to set some thread specific parameters. More...
#include <async_function_handler.hpp>
Public Member Functions | |
void | init (std::function< T(const rclcpp::Time &, const rclcpp::Duration &)> callback, int thread_priority=50) |
Initialize the AsyncFunctionHandler with the callback and thread_priority. | |
void | init (std::function< T(const rclcpp::Time &, const rclcpp::Duration &)> callback, std::function< bool()> trigger_predicate, int thread_priority=50) |
Initialize the AsyncFunctionHandler with the callback, trigger_predicate and thread_priority. | |
void | init (std::function< T(const rclcpp::Time &, const rclcpp::Duration &)> callback, const AsyncFunctionHandlerParams ¶ms) |
std::pair< bool, T > | trigger_async_callback (const rclcpp::Time &time, const rclcpp::Duration &period) |
Triggers the async callback method cycle. | |
T | get_last_return_value () const |
Get the last return value of the async callback method. | |
const rclcpp::Time & | get_current_callback_time () const |
Get the current callback time. | |
const rclcpp::Duration & | get_current_callback_period () const |
Get the current callback period. | |
void | reset_variables () |
Resets the internal variables of the AsyncFunctionHandler. | |
bool | wait_for_trigger_cycle_to_finish () |
Waits until the current async callback method trigger cycle is finished. | |
bool | pause_execution () |
Pauses the execution of the async callback thread. | |
bool | is_initialized () const |
Check if the AsyncFunctionHandler is initialized. | |
void | join_async_callback_thread () |
Join the async callback thread. | |
bool | is_running () const |
Check if the async worker thread is running. | |
bool | is_stopped () const |
Check if the async callback is triggered to stop the cycle. | |
bool | is_paused () const |
Check if the async callback thread is paused. | |
std::thread & | get_thread () |
Get the async worker thread. | |
const std::thread & | get_thread () const |
Get the const version of async worker thread. | |
const AsyncFunctionHandlerParams & | get_params () const |
Get the parameters used to configure the AsyncFunctionHandler. | |
bool | is_trigger_cycle_in_progress () const |
Check if the async callback method is in progress. | |
void | stop_thread () |
Stops the callback thread. | |
std::chrono::nanoseconds | get_last_execution_time () const |
Get the last execution time of the async callback method. | |
void | start_thread () |
Initializes and starts the callback thread. | |
Class to handle asynchronous function calls. AsyncFunctionHandler is a class that allows the user to have a asynchronous call to the parsed method and be able to set some thread specific parameters.
|
inline |
Get the current callback period.
|
inline |
Get the current callback time.
|
inline |
Get the last execution time of the async callback method.
|
inline |
Get the last return value of the async callback method.
|
inline |
Get the parameters used to configure the AsyncFunctionHandler.
|
inline |
Get the async worker thread.
|
inline |
Get the const version of async worker thread.
|
inline |
Initialize the AsyncFunctionHandler with the callback and thread_priority.
callback | Function that will be called asynchronously If the AsyncFunctionHandler is already initialized and is running, it will throw a runtime error. If the parsed functions are not valid, it will throw a runtime error. |
|
inline |
Initialize the AsyncFunctionHandler with the callback, trigger_predicate and thread_priority.
callback | Function that will be called asynchronously. |
trigger_predicate | Predicate function that will be called to check if the async callback method should be triggered or not. |
thread_priority | Priority of the async worker thread. |
If the AsyncFunctionHandler is already initialized and is running, it will throw a runtime error. If the parsed functions are not valid, it will throw a runtime error.
|
inline |
Check if the AsyncFunctionHandler is initialized.
|
inline |
Check if the async callback thread is paused.
|
inline |
Check if the async worker thread is running.
|
inline |
Check if the async callback is triggered to stop the cycle.
|
inline |
Check if the async callback method is in progress.
|
inline |
Join the async callback thread.
If the async method is running, it will join the async thread. If the async method is not running, it will return immediately.
|
inline |
Pauses the execution of the async callback thread.
If the async method is running, it will pause the async thread until the next trigger cycle. If the async method is not running, it will return immediately.
|
inline |
Resets the internal variables of the AsyncFunctionHandler.
A method to reset the internal variables of the AsyncFunctionHandler. It will reset the async callback return value, exception pointer, and the trigger status.
|
inline |
Initializes and starts the callback thread.
If the worker thread is not running, it will start the async callback thread. If the worker thread is already configured and running, does nothing and returns immediately.
|
inline |
Stops the callback thread.
If the async method is running, it will notify the async thread to stop and then joins the async thread.
|
inline |
Triggers the async callback method cycle.
time | Current time |
period | Current period |
reset_variables
method should be invoked.
|
inline |
Waits until the current async callback method trigger cycle is finished.
If the async method is running, it will wait for the current async method call to finish.