Skip to content

Commit

Permalink
Remove unused scoped_unlock, unlock_guard_try
Browse files Browse the repository at this point in the history
  • Loading branch information
K-ballo committed Feb 25, 2018
1 parent 9cdd6bc commit fa0aa95
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 57 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Expand Up @@ -915,6 +915,14 @@ if(HPX_WITH_QUEUE_COMPATIBILITY)
hpx_add_config_define(HPX_HAVE_QUEUE_COMPATIBILITY)
endif()

# HPX_WITH_SCOPED_UNLOCK_COMPATIBILITY: introduced in V1.1.0
hpx_option(HPX_WITH_SCOPED_UNLOCK_COMPATIBILITY BOOL
"Enable backwards compatibility for scoped_unlock utility (default: OFF)"
OFF ADVANCED)
if(HPX_WITH_SCOPED_UNLOCK_COMPATIBILITY)
hpx_add_config_define(HPX_HAVE_SCOPED_UNLOCK_COMPATIBILITY)
endif()

# BADBAD: This enables an overload of swap which is necessary to work around the
# problems caused by zip_iterator not being a real random access iterator.
# Dereferencing zip_iterator does not yield a true reference but
Expand Down
6 changes: 3 additions & 3 deletions hpx/lcos/local/channel.hpp
Expand Up @@ -19,7 +19,7 @@
#include <hpx/util/atomic_count.hpp>
#include <hpx/util/iterator_facade.hpp>
#include <hpx/util/register_locks.hpp>
#include <hpx/util/scoped_unlock.hpp>
#include <hpx/util/unlock_guard.hpp>
#include <hpx/util/unused.hpp>

#include <boost/intrusive_ptr.hpp>
Expand Down Expand Up @@ -206,7 +206,7 @@ namespace hpx { namespace lcos { namespace local
std::exception_ptr e;

{
util::scoped_unlock<std::unique_lock<mutex_type> > ul(l);
util::unlock_guard<std::unique_lock<mutex_type>> ul(l);
e = HPX_GET_EXCEPTION(
hpx::future_cancelled, hpx::lightweight,
"hpx::lcos::local::close",
Expand Down Expand Up @@ -478,7 +478,7 @@ namespace hpx { namespace lcos { namespace local
// canceled at this point
std::exception_ptr e;
{
util::scoped_unlock<std::unique_lock<mutex_type> > ul(l);
util::unlock_guard<std::unique_lock<mutex_type>> ul(l);
e = std::exception_ptr(
HPX_GET_EXCEPTION(hpx::future_cancelled,
"hpx::lcos::local::close",
Expand Down
35 changes: 13 additions & 22 deletions hpx/util/scoped_unlock.hpp
@@ -1,33 +1,24 @@
// Copyright (c) 2007-2008 Chirag Dekate, Hartmut Kaiser
// Copyright (c) 2015 Agustin Berge
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#if !defined(HPX_UTIL_SCOPED_UNLOCK_JUN_17_2008_1131AM)
#define HPX_UTIL_SCOPED_UNLOCK_JUN_17_2008_1131AM
#ifndef HPX_UTIL_SCOPED_UNLOCK_HPP
#define HPX_UTIL_SCOPED_UNLOCK_HPP

#include <hpx/config.hpp>

#if defined(HPX_HAVE_SCOPED_UNLOCK_COMPATIBILITY)
#include <hpx/util/unlock_guard.hpp>

///////////////////////////////////////////////////////////////////////////////
namespace hpx { namespace util
{
///////////////////////////////////////////////////////////////////////////
// This is a helper structure to make sure a lock gets unlocked and locked
// again in a scope.
template <typename Lock>
struct scoped_unlock
{
scoped_unlock(Lock& l) : l_(l)
{
l_.unlock();
}
~scoped_unlock()
{
l_.lock();
}

Lock& l_;
};

///////////////////////////////////////////////////////////////////////////////
using scoped_unlock = unlock_guard<Lock>;
}}

#else
# error This header exists for compatibility reasons, use <hpx/util/unlock_guard.hpp> instead.
#endif

#endif /*HPX_UTIL_SCOPED_UNLOCK_HPP*/
27 changes: 1 addition & 26 deletions hpx/util/unlock_guard.hpp
Expand Up @@ -9,7 +9,6 @@

#include <hpx/config.hpp>

///////////////////////////////////////////////////////////////////////////////
namespace hpx { namespace util
{
///////////////////////////////////////////////////////////////////////////
Expand All @@ -22,7 +21,7 @@ namespace hpx { namespace util
HPX_NON_COPYABLE(unlock_guard);

public:
typedef Mutex mutex_type;
using mutex_type = Mutex;

explicit unlock_guard(Mutex& m)
: m_(m)
Expand All @@ -38,30 +37,6 @@ namespace hpx { namespace util
private:
Mutex& m_;
};

template <typename Mutex>
class unlock_guard_try
{
public:
HPX_NON_COPYABLE(unlock_guard_try);

public:
typedef Mutex mutex_type;

explicit unlock_guard_try(Mutex& m)
: m_(m)
{
m_.unlock();
}

~unlock_guard_try()
{
m_.try_lock();
}

private:
Mutex& m_;
};
}}

#endif /*HPX_UTIL_UNLOCK_GUARD_HPP*/
4 changes: 2 additions & 2 deletions src/runtime/naming/name.cpp
Expand Up @@ -24,7 +24,7 @@
#include <hpx/util/assert.hpp>
#include <hpx/util/bind.hpp>
#include <hpx/util/logging.hpp>
#include <hpx/util/scoped_unlock.hpp>
#include <hpx/util/unlock_guard.hpp>

#include <boost/io/ios_state.hpp>

Expand Down Expand Up @@ -444,7 +444,7 @@ namespace hpx { namespace naming

std::int64_t result = 0;
{
hpx::util::scoped_unlock<std::unique_lock<gid_type::mutex_type> >
hpx::util::unlock_guard<std::unique_lock<gid_type::mutex_type>>
ul(l);
result = agas::incref(launch::sync, unlocked_gid, added_credit);
}
Expand Down
8 changes: 4 additions & 4 deletions src/util/ini.cpp
Expand Up @@ -27,7 +27,7 @@
#include <hpx/util/assert.hpp>
#include <hpx/util/ini.hpp>
#include <hpx/util/register_locks.hpp>
#include <hpx/util/scoped_unlock.hpp>
#include <hpx/util/unlock_guard.hpp>
#include <hpx/runtime/serialization/serialize.hpp>
#include <hpx/runtime/serialization/map.hpp>

Expand Down Expand Up @@ -486,7 +486,7 @@ void section::add_entry (std::unique_lock<mutex_type>& l,
std::string value = it->second.first;
entry_changed_func f = it->second.second;

hpx::util::scoped_unlock<std::unique_lock<mutex_type> > ul(l);
hpx::util::unlock_guard<std::unique_lock<mutex_type>> ul(l);
f(fullkey, value);
}
}
Expand Down Expand Up @@ -534,7 +534,7 @@ void section::add_entry (std::unique_lock<mutex_type>& l,
std::string value = it->second.first;
entry_changed_func f = it->second.second;

hpx::util::scoped_unlock<std::unique_lock<mutex_type> > ul(l);
hpx::util::unlock_guard<std::unique_lock<mutex_type>> ul(l);
f(fullkey, value);
}
}
Expand All @@ -551,7 +551,7 @@ void section::add_entry (std::unique_lock<mutex_type>& l,
std::string value = p.first->second.first;
entry_changed_func f = p.first->second.second;

hpx::util::scoped_unlock<std::unique_lock<mutex_type> > ul(l);
hpx::util::unlock_guard<std::unique_lock<mutex_type>> ul(l);
f(key, value);
}
}
Expand Down
5 changes: 5 additions & 0 deletions tests/headers/CMakeLists.txt
Expand Up @@ -22,6 +22,11 @@ set(exclude_from_headers
"parallel/executors/timed_execution_fwd.hpp"
)

if(NOT HPX_WITH_SCOPED_UNLOCK_COMPATIBILITY)
set(exclude_from_all_headers ${exclude_from_all_headers} "util/scoped_unlock.hpp")
set(exclude_from_headers ${exclude_from_headers} "util/scoped_unlock.hpp")
endif()

# If we compile with the MPI parcelport enabled, we need to additionally
# add the MPI include path here, because for the main library, it's only
# added for the plugin.
Expand Down

0 comments on commit fa0aa95

Please sign in to comment.