use scope exit to ensure spinning is reset
This commit is contained in:
parent
9dce2808ea
commit
2b342357d9
3 changed files with 10 additions and 0 deletions
|
@ -16,6 +16,8 @@
|
|||
|
||||
#include "rcl_interfaces/msg/intra_process_message.hpp"
|
||||
|
||||
#include "./scope_exit.hpp"
|
||||
|
||||
using rclcpp::executor::AnyExecutable;
|
||||
using rclcpp::executor::Executor;
|
||||
|
||||
|
@ -108,6 +110,7 @@ Executor::spin_node_some(rclcpp::node::Node::SharedPtr node)
|
|||
void
|
||||
Executor::spin_some()
|
||||
{
|
||||
RCLCPP_SCOPE_EXIT(this->spinning.store(false); );
|
||||
if (spinning.exchange(true)) {
|
||||
throw std::runtime_error("spin_some() called while already spinning");
|
||||
}
|
||||
|
@ -121,6 +124,7 @@ Executor::spin_some()
|
|||
void
|
||||
Executor::spin_once(std::chrono::nanoseconds timeout)
|
||||
{
|
||||
RCLCPP_SCOPE_EXIT(this->spinning.store(false); );
|
||||
if (spinning.exchange(true)) {
|
||||
throw std::runtime_error("spin_once() called while already spinning");
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
#include "rclcpp/utilities.hpp"
|
||||
|
||||
#include "../scope_exit.hpp"
|
||||
|
||||
using rclcpp::executors::multi_threaded_executor::MultiThreadedExecutor;
|
||||
|
||||
MultiThreadedExecutor::MultiThreadedExecutor(rclcpp::memory_strategy::MemoryStrategy::SharedPtr ms)
|
||||
|
@ -36,6 +38,7 @@ MultiThreadedExecutor::~MultiThreadedExecutor() {}
|
|||
void
|
||||
MultiThreadedExecutor::spin()
|
||||
{
|
||||
RCLCPP_SCOPE_EXIT(this->spinning.store(false); );
|
||||
if (spinning.exchange(true)) {
|
||||
throw std::runtime_error("spin() called while already spinning");
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
#include <rclcpp/executors/single_threaded_executor.hpp>
|
||||
|
||||
#include "../scope_exit.hpp"
|
||||
|
||||
using rclcpp::executors::single_threaded_executor::SingleThreadedExecutor;
|
||||
|
||||
SingleThreadedExecutor::SingleThreadedExecutor(
|
||||
|
@ -26,6 +28,7 @@ SingleThreadedExecutor::~SingleThreadedExecutor() {}
|
|||
void
|
||||
SingleThreadedExecutor::spin()
|
||||
{
|
||||
RCLCPP_SCOPE_EXIT(this->spinning.store(false); );
|
||||
if (spinning.exchange(true)) {
|
||||
throw std::runtime_error("spin_some() called while already spinning");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue