Fix a concurrency problem in the multithreaded executor (#703)

Both, the `Executor::execute_any_executable` and the destructor for the `AnyExecutable` object used by the multithreaded executor, reset the `can_be_taken_from_` flag on a MutuallyExclusive group. This cause the variable to get out of sync and threads to process executables out of sequence.

This fix clears the callback group variable of the `AnyExecutable` instance effectively preventing its destructor from modifying the variable at the wrong time.

Issue: #702
Signed-off-by: Guillaume Autran <gautran@clearpath.ai>
This commit is contained in:
Guillaume Autran 2019-04-22 14:39:32 -04:00 committed by Shane Loretz
parent ddf4d345b3
commit 97ed34a042

View file

@ -101,5 +101,8 @@ MultiThreadedExecutor::run(size_t)
scheduled_timers_.erase(it);
}
}
// Clear the callback_group to prevent the AnyExecutable destructor from
// resetting the callback group `can_be_taken_from`
any_exec.callback_group.reset();
}
}