Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use recursive_mutex to allow callbacks to reenter #123

Open
wants to merge 1 commit into
base: rolling
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions rmw_connextdds_common/include/rmw_connextdds/rmw_waitset_std.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class RMW_Connext_Condition
bool & already_active,
FunctorT && check_trigger)
{
std::lock_guard<std::mutex> lock(this->mutex_internal);
std::lock_guard<std::recursive_mutex> lock(this->mutex_internal);
already_active = check_trigger();
if (!already_active) {
this->waitset_mutex = waitset_mutex;
Expand All @@ -95,7 +95,7 @@ class RMW_Connext_Condition
void
detach(FunctorT && on_detached)
{
std::lock_guard<std::mutex> lock(this->mutex_internal);
std::lock_guard<std::recursive_mutex> lock(this->mutex_internal);
this->waitset_mutex = nullptr;
this->waitset_condition = nullptr;
on_detached();
Expand All @@ -107,7 +107,7 @@ class RMW_Connext_Condition
void
update_state(FunctorT && update_condition, const bool notify)
{
std::lock_guard<std::mutex> internal_lock(this->mutex_internal);
std::lock_guard<std::recursive_mutex> internal_lock(this->mutex_internal);

if (nullptr != this->waitset_mutex) {
std::lock_guard<std::mutex> lock(*this->waitset_mutex);
Expand All @@ -125,7 +125,7 @@ class RMW_Connext_Condition
void
perform_action_and_update_state(FunctorA && action, FunctorT && update_condition)
{
std::lock_guard<std::mutex> internal_lock(this->mutex_internal);
std::lock_guard<std::recursive_mutex> internal_lock(this->mutex_internal);

action();

Expand All @@ -138,7 +138,7 @@ class RMW_Connext_Condition
}

protected:
std::mutex mutex_internal;
std::recursive_mutex mutex_internal;
std::mutex * waitset_mutex;
std::condition_variable * waitset_condition;

Expand Down