Realistic 3D camera system
3D camera system components
gcc_sync_fenced_block.hpp
Go to the documentation of this file.
1 //
2 // detail/gcc_sync_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_GCC_SYNC_FENCED_BLOCK_HPP
12 #define ASIO_DETAIL_GCC_SYNC_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(__GNUC__) \
21  && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4)) \
22  && !defined(__INTEL_COMPILER) && !defined(__ICL) \
23  && !defined(__ICC) && !defined(__ECC) && !defined(__PATHSCALE__)
24 
26 
27 namespace asio {
28 namespace detail {
29 
30 class gcc_sync_fenced_block
31  : private noncopyable
32 {
33 public:
34  enum half_or_full_t { half, full };
35 
36  // Constructor.
37  explicit gcc_sync_fenced_block(half_or_full_t)
38  : value_(0)
39  {
40  __sync_lock_test_and_set(&value_, 1);
41  }
42 
43  // Destructor.
44  ~gcc_sync_fenced_block()
45  {
46  __sync_lock_release(&value_);
47  }
48 
49 private:
50  int value_;
51 };
52 
53 } // namespace detail
54 } // namespace asio
55 
57 
58 #endif // defined(__GNUC__)
59  // && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4))
60  // && !defined(__INTEL_COMPILER) && !defined(__ICL)
61  // && !defined(__ICC) && !defined(__ECC) && !defined(__PATHSCALE__)
62 
63 #endif // ASIO_DETAIL_GCC_SYNC_FENCED_BLOCK_HPP