• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Distributed under the Boost Software License, Version 1.0. (See
2 // accompanying file LICENSE_1_0.txt or copy at
3 // http://www.boost.org/LICENSE_1_0.txt)
4 // (C) Copyright 2012 Vicente J. Botet Escriba
5 
6 #ifndef BOOST_THREAD_SHARED_LOCK_GUARD_HPP
7 #define BOOST_THREAD_SHARED_LOCK_GUARD_HPP
8 #include <boost/thread/detail/config.hpp>
9 //#include <boost/thread/locks.hpp>
10 #include <boost/thread/lock_options.hpp>
11 #include <boost/thread/detail/delete.hpp>
12 
13 namespace boost
14 {
15 
16     template<typename SharedMutex>
17     class shared_lock_guard
18     {
19     private:
20         SharedMutex& m;
21 
22     public:
23         typedef SharedMutex mutex_type;
24         BOOST_THREAD_NO_COPYABLE(shared_lock_guard)
shared_lock_guard(SharedMutex & m_)25         explicit shared_lock_guard(SharedMutex& m_):
26             m(m_)
27         {
28             m.lock_shared();
29         }
shared_lock_guard(SharedMutex & m_,adopt_lock_t)30         shared_lock_guard(SharedMutex& m_,adopt_lock_t):
31             m(m_)
32         {}
~shared_lock_guard()33         ~shared_lock_guard()
34         {
35             m.unlock_shared();
36         }
37     };
38 
39 #ifdef BOOST_THREAD_NO_AUTO_DETECT_MUTEX_TYPES
40 
41     template<typename T>
42     struct is_mutex_type<shared_lock_guard<T> >
43     {
44         BOOST_STATIC_CONSTANT(bool, value = true);
45     };
46 
47 
48 #endif
49 
50 
51 }
52 
53 #endif // header
54