Imported Upstream version 1.57.0
[platform/upstream/boost.git] / boost / thread / is_locked_by_this_thread.hpp
1 // (C) Copyright 2012 Vicente J. Botet Escriba
2 // Distributed under the Boost Software License, Version 1.0. (See
3 // accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
5
6
7 #ifndef BOOST_THREAD_IS_LOCKED_BY_THIS_THREAD_HPP
8 #define BOOST_THREAD_IS_LOCKED_BY_THIS_THREAD_HPP
9
10 #include <boost/thread/detail/config.hpp>
11
12 #include <boost/config/abi_prefix.hpp>
13
14 namespace boost
15 {
16   template <typename Lockable>
17   class testable_mutex;
18
19   /**
20    * Overloaded function used to check if the mutex is locked when it is testable and do nothing otherwise.
21    *
22    * This function is used usually to assert the pre-condition when the function can only be called when the mutex
23    * must be locked by the current thread.
24    */
25   template <typename Lockable>
26   bool is_locked_by_this_thread(testable_mutex<Lockable> const& mtx)
27   {
28     return mtx.is_locked_by_this_thread();
29   }
30   template <typename Lockable>
31   bool is_locked_by_this_thread(Lockable const&)
32   {
33     return true;
34   }
35 }
36
37 #include <boost/config/abi_suffix.hpp>
38
39 #endif // header