Line | % of fetches | Source |
---|---|---|
1 | // Copyright (c) 2007-2008 Chirag Dekate, Hartmut Kaiser | |
2 | // Copyright (c) 2015 Agustin Berge | |
3 | // | |
4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | |
5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
6 | ||
7 | #ifndef HPX_UTIL_UNLOCK_GUARD_HPP | |
8 | #define HPX_UTIL_UNLOCK_GUARD_HPP | |
9 | ||
10 | #include <hpx/config.hpp> | |
11 | ||
12 | /////////////////////////////////////////////////////////////////////////////// | |
13 | namespace hpx { namespace util | |
14 | { | |
15 | /////////////////////////////////////////////////////////////////////////// | |
16 | // This is a helper structure to make sure a lock gets unlocked and locked | |
17 | // again in a scope. | |
18 | template <typename Mutex> | |
19 | class unlock_guard | |
20 | { | |
21 | HPX_NON_COPYABLE(unlock_guard); | |
22 | ||
23 | public: | |
24 | typedef Mutex mutex_type; | |
25 | ||
26 | explicit unlock_guard(Mutex& m) | |
27 | : m_(m) | |
28 | { | |
29 | m_.unlock(); | |
30 | } | |
31 | ||
32 | ~unlock_guard() | |
33 | { | |
34 | m_.lock(); | |
35 | } | |
36 | ||
37 | private: | |
38 | Mutex& m_; | |
39 | }; | |
40 | }} | |
41 | ||
42 | #endif /*HPX_UTIL_UNLOCK_GUARD_HPP*/ | |
43 |
Copyright (c) 2006-2012 Rogue Wave Software, Inc. All Rights Reserved.
Patents pending.