only set scope exit after it was determined that spinning was changed to true
This commit is contained in:
parent
f1e7ea5ca0
commit
1c9eb0b367
3 changed files with 4 additions and 4 deletions
|
@ -110,10 +110,10 @@ Executor::spin_node_some(rclcpp::node::Node::SharedPtr node)
|
||||||
void
|
void
|
||||||
Executor::spin_some()
|
Executor::spin_some()
|
||||||
{
|
{
|
||||||
RCLCPP_SCOPE_EXIT(this->spinning.store(false); );
|
|
||||||
if (spinning.exchange(true)) {
|
if (spinning.exchange(true)) {
|
||||||
throw std::runtime_error("spin_some() called while already spinning");
|
throw std::runtime_error("spin_some() called while already spinning");
|
||||||
}
|
}
|
||||||
|
RCLCPP_SCOPE_EXIT(this->spinning.store(false); );
|
||||||
AnyExecutable::SharedPtr any_exec;
|
AnyExecutable::SharedPtr any_exec;
|
||||||
while ((any_exec = get_next_executable(std::chrono::milliseconds::zero())) && spinning.load()) {
|
while ((any_exec = get_next_executable(std::chrono::milliseconds::zero())) && spinning.load()) {
|
||||||
execute_any_executable(any_exec);
|
execute_any_executable(any_exec);
|
||||||
|
@ -123,10 +123,10 @@ Executor::spin_some()
|
||||||
void
|
void
|
||||||
Executor::spin_once(std::chrono::nanoseconds timeout)
|
Executor::spin_once(std::chrono::nanoseconds timeout)
|
||||||
{
|
{
|
||||||
RCLCPP_SCOPE_EXIT(this->spinning.store(false); );
|
|
||||||
if (spinning.exchange(true)) {
|
if (spinning.exchange(true)) {
|
||||||
throw std::runtime_error("spin_once() called while already spinning");
|
throw std::runtime_error("spin_once() called while already spinning");
|
||||||
}
|
}
|
||||||
|
RCLCPP_SCOPE_EXIT(this->spinning.store(false); );
|
||||||
auto any_exec = get_next_executable(timeout);
|
auto any_exec = get_next_executable(timeout);
|
||||||
if (any_exec) {
|
if (any_exec) {
|
||||||
execute_any_executable(any_exec);
|
execute_any_executable(any_exec);
|
||||||
|
|
|
@ -38,10 +38,10 @@ MultiThreadedExecutor::~MultiThreadedExecutor() {}
|
||||||
void
|
void
|
||||||
MultiThreadedExecutor::spin()
|
MultiThreadedExecutor::spin()
|
||||||
{
|
{
|
||||||
RCLCPP_SCOPE_EXIT(this->spinning.store(false); );
|
|
||||||
if (spinning.exchange(true)) {
|
if (spinning.exchange(true)) {
|
||||||
throw std::runtime_error("spin() called while already spinning");
|
throw std::runtime_error("spin() called while already spinning");
|
||||||
}
|
}
|
||||||
|
RCLCPP_SCOPE_EXIT(this->spinning.store(false); );
|
||||||
std::vector<std::thread> threads;
|
std::vector<std::thread> threads;
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> wait_lock(wait_mutex_);
|
std::lock_guard<std::mutex> wait_lock(wait_mutex_);
|
||||||
|
|
|
@ -28,10 +28,10 @@ SingleThreadedExecutor::~SingleThreadedExecutor() {}
|
||||||
void
|
void
|
||||||
SingleThreadedExecutor::spin()
|
SingleThreadedExecutor::spin()
|
||||||
{
|
{
|
||||||
RCLCPP_SCOPE_EXIT(this->spinning.store(false); );
|
|
||||||
if (spinning.exchange(true)) {
|
if (spinning.exchange(true)) {
|
||||||
throw std::runtime_error("spin_some() called while already spinning");
|
throw std::runtime_error("spin_some() called while already spinning");
|
||||||
}
|
}
|
||||||
|
RCLCPP_SCOPE_EXIT(this->spinning.store(false); );
|
||||||
while (rclcpp::utilities::ok() && spinning.load()) {
|
while (rclcpp::utilities::ok() && spinning.load()) {
|
||||||
auto any_exec = get_next_executable();
|
auto any_exec = get_next_executable();
|
||||||
execute_any_executable(any_exec);
|
execute_any_executable(any_exec);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue