Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
brjsp committed Jan 14, 2018
1 parent c038261 commit 6c0f564
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion hpx/lcos/local/condition_variable.hpp
Expand Up @@ -51,9 +51,12 @@ namespace hpx { namespace lcos { namespace local
{
HPX_ASSERT_OWNS_LOCK(lock);
util::ignore_while_checking<std::unique_lock<mutex> > il(&lock);

std::unique_lock<mutex_type> l(mtx_);
util::unlock_guard<std::unique_lock<mutex> > unlock(lock);
//The following ensures that the inner lock will be unlocked
//before the outer to avoid deadlock (fixes issue #3608)
std::lock_guard<std::unique_lock<mutex_type> > unlock_next(
l, std::adopt_lock);

cond_.wait(l, ec);

Expand Down Expand Up @@ -85,6 +88,10 @@ namespace hpx { namespace lcos { namespace local
util::ignore_while_checking<std::unique_lock<mutex> > il(&lock);
std::unique_lock<mutex_type> l(mtx_);
util::unlock_guard<std::unique_lock<mutex> > unlock(lock);
//The following ensures that the inner lock will be unlocked
//before the outer to avoid deadlock (fixes issue #3608)
std::lock_guard<std::unique_lock<mutex_type> > unlock_next(
l, std::adopt_lock);

threads::thread_state_ex_enum const reason =
cond_.wait_until(l, abs_time, ec);
Expand Down Expand Up @@ -163,6 +170,10 @@ namespace hpx { namespace lcos { namespace local
util::ignore_all_while_checking ignore_lock;
std::unique_lock<mutex_type> l(mtx_);
util::unlock_guard<Lock> unlock(lock);
//The following ensures that the inner lock will be unlocked
//before the outer to avoid deadlock (fixes issue #3608)
std::lock_guard<std::unique_lock<mutex_type> > unlock_next(
l, std::adopt_lock);

cond_.wait(l, ec);

Expand Down Expand Up @@ -194,6 +205,10 @@ namespace hpx { namespace lcos { namespace local
util::ignore_all_while_checking ignore_lock;
std::unique_lock<mutex_type> l(mtx_);
util::unlock_guard<Lock> unlock(lock);
//The following ensures that the inner lock will be unlocked
//before the outer to avoid deadlock (fixes issue #3608)
std::lock_guard<std::unique_lock<mutex_type> > unlock_next(
l, std::adopt_lock);

threads::thread_state_ex_enum const reason =
cond_.wait_until(l, abs_time, ec);
Expand Down

0 comments on commit 6c0f564

Please sign in to comment.