Realistic 3D camera system
3D camera system components
win_mutex.hpp
Go to the documentation of this file.
1 //
2 // detail/win_mutex.hpp
3 // ~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 //
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)
9 //
10 
11 #ifndef ASIO_DETAIL_WIN_MUTEX_HPP
12 #define ASIO_DETAIL_WIN_MUTEX_HPP
13 
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 # pragma once
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 
18 #include "asio/detail/config.hpp"
19 
20 #if defined(ASIO_WINDOWS)
21 
25 
27 
28 namespace asio {
29 namespace detail {
30 
31 class win_mutex
32  : private noncopyable
33 {
34 public:
35  typedef asio::detail::scoped_lock<win_mutex> scoped_lock;
36 
37  // Constructor.
38  ASIO_DECL win_mutex();
39 
40  // Destructor.
41  ~win_mutex()
42  {
43  ::DeleteCriticalSection(&crit_section_);
44  }
45 
46  // Lock the mutex.
47  void lock()
48  {
49  ::EnterCriticalSection(&crit_section_);
50  }
51 
52  // Unlock the mutex.
53  void unlock()
54  {
55  ::LeaveCriticalSection(&crit_section_);
56  }
57 
58 private:
59  // Initialisation must be performed in a separate function to the constructor
60  // since the compiler does not support the use of structured exceptions and
61  // C++ exceptions in the same function.
62  ASIO_DECL int do_init();
63 
64  ::CRITICAL_SECTION crit_section_;
65 };
66 
67 } // namespace detail
68 } // namespace asio
69 
71 
72 #if defined(ASIO_HEADER_ONLY)
74 #endif // defined(ASIO_HEADER_ONLY)
75 
76 #endif // defined(ASIO_WINDOWS)
77 
78 #endif // ASIO_DETAIL_WIN_MUTEX_HPP
#define ASIO_DECL
Definition: config.hpp:43