• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2   Provides a basic subset of boost::unique_lock functionality.  Provided only because
3   including boost/thread/locks.hpp requires linking to thread library
4 */
5 // Copyright Frank Mori Hess 2008.
6 // Distributed under the Boost Software License, Version
7 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
9 
10 // See http://www.boost.org/libs/signals2 for library home page.
11 
12 #ifndef BOOST_SIGNALS2_UNIQUE_LOCK_HPP
13 #define BOOST_SIGNALS2_UNIQUE_LOCK_HPP
14 
15 #include <boost/noncopyable.hpp>
16 
17 namespace boost
18 {
19   namespace signals2
20   {
21     namespace detail
22     {
23       template<typename Mutex>
24       class unique_lock: public noncopyable
25       {
26       public:
unique_lock(Mutex & m)27         unique_lock(Mutex &m): _mutex(m)
28         {
29           _mutex.lock();
30         }
~unique_lock()31         ~unique_lock()
32         {
33           _mutex.unlock();
34         }
35       private:
36         Mutex &_mutex;
37       };
38     } // namespace detail
39   } // namespace signals2
40 } // namespace boost
41 
42 #endif  // BOOST_SIGNALS2_UNIQUE_LOCK_HPP
43