/Src/Dependencies/Boost/boost/signals2/detail/unique_lock.hpp

http://hadesmem.googlecode.com/ · C++ Header · 42 lines · 28 code · 5 blank · 9 comment · 0 complexity · 305a935b5693bfe2060b086204f7436d MD5 · raw file

  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. // See http://www.boost.org/libs/signals2 for library home page.
  10. #ifndef BOOST_SIGNALS2_UNIQUE_LOCK_HPP
  11. #define BOOST_SIGNALS2_UNIQUE_LOCK_HPP
  12. #include <boost/noncopyable.hpp>
  13. namespace boost
  14. {
  15. namespace signals2
  16. {
  17. namespace detail
  18. {
  19. template<typename Mutex>
  20. class unique_lock: public noncopyable
  21. {
  22. public:
  23. unique_lock(Mutex &m): _mutex(m)
  24. {
  25. _mutex.lock();
  26. }
  27. ~unique_lock()
  28. {
  29. _mutex.unlock();
  30. }
  31. private:
  32. Mutex &_mutex;
  33. };
  34. } // namespace detail
  35. } // namespace signals2
  36. } // namespace boost
  37. #endif // BOOST_SIGNALS2_UNIQUE_LOCK_HPP