2 // detail/scoped_lock.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~
5 // Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
11 #ifndef BOOST_ASIO_DETAIL_SCOPED_LOCK_HPP
12 #define BOOST_ASIO_DETAIL_SCOPED_LOCK_HPP
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 #include <boost/asio/detail/noncopyable.hpp>
20 #include <boost/asio/detail/push_options.hpp>
26 // Helper class to lock and unlock a mutex automatically.
27 template <typename Mutex>
32 // Tag type used to distinguish constructors.
33 enum adopt_lock_t { adopt_lock };
35 // Constructor adopts a lock that is already held.
36 scoped_lock(Mutex& m, adopt_lock_t)
42 // Constructor acquires the lock.
43 explicit scoped_lock(Mutex& m)
50 // Destructor releases the lock.
57 // Explicitly acquire the lock.
67 // Explicitly release the lock.
77 // Test whether the lock is held.
83 // Get the underlying mutex.
90 // The underlying mutex.
93 // Whether the mutex is currently locked or unlocked.
101 #include <boost/asio/detail/pop_options.hpp>
103 #endif // BOOST_ASIO_DETAIL_SCOPED_LOCK_HPP