Realistic 3D camera system
3D camera system components
win_fenced_block.hpp
Go to the documentation of this file.
1 //
2 // detail/win_fenced_block.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_FENCED_BLOCK_HPP
12 #define ASIO_DETAIL_WIN_FENCED_BLOCK_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) && !defined(UNDER_CE)
21 
23 
25 
26 namespace asio {
27 namespace detail {
28 
29 class win_fenced_block
30  : private noncopyable
31 {
32 public:
33  enum half_t { half };
34  enum full_t { full };
35 
36  // Constructor for a half fenced block.
37  explicit win_fenced_block(half_t)
38  {
39  }
40 
41  // Constructor for a full fenced block.
42  explicit win_fenced_block(full_t)
43  {
44 #if defined(__BORLANDC__)
45  LONG barrier = 0;
46  ::InterlockedExchange(&barrier, 1);
47 #elif defined(ASIO_MSVC) \
48  && ((ASIO_MSVC < 1400) || !defined(MemoryBarrier))
49 # if defined(_M_IX86)
50 # pragma warning(push)
51 # pragma warning(disable:4793)
52  LONG barrier;
53  __asm { xchg barrier, eax }
54 # pragma warning(pop)
55 # endif // defined(_M_IX86)
56 #else
57  MemoryBarrier();
58 #endif
59  }
60 
61  // Destructor.
62  ~win_fenced_block()
63  {
64 #if defined(__BORLANDC__)
65  LONG barrier = 0;
66  ::InterlockedExchange(&barrier, 1);
67 #elif defined(ASIO_MSVC) \
68  && ((ASIO_MSVC < 1400) || !defined(MemoryBarrier))
69 # if defined(_M_IX86)
70 # pragma warning(push)
71 # pragma warning(disable:4793)
72  LONG barrier;
73  __asm { xchg barrier, eax }
74 # pragma warning(pop)
75 # endif // defined(_M_IX86)
76 #else
77  MemoryBarrier();
78 #endif
79  }
80 };
81 
82 } // namespace detail
83 } // namespace asio
84 
86 
87 #endif // defined(ASIO_WINDOWS) && !defined(UNDER_CE)
88 
89 #endif // ASIO_DETAIL_WIN_FENCED_BLOCK_HPP