PageRenderTime 36ms CodeModel.GetById 29ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/boost/asio/detail/gcc_sync_fenced_block.hpp

http://hadesmem.googlecode.com/
C++ Header | 63 lines | 36 code | 13 blank | 14 comment | 10 complexity | b7606adaef66985bdcdd52be84317dda MD5 | raw file
 1//
 2// detail/gcc_sync_fenced_block.hpp
 3// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 4//
 5// Copyright (c) 2003-2011 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 BOOST_ASIO_DETAIL_GCC_SYNC_FENCED_BLOCK_HPP
12#define BOOST_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 <boost/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
25#include <boost/asio/detail/push_options.hpp>
26
27namespace boost {
28namespace asio {
29namespace detail {
30
31class gcc_sync_fenced_block
32  : private noncopyable
33{
34public:
35  // Constructor.
36  gcc_sync_fenced_block()
37    : value_(0)
38  {
39    __sync_lock_test_and_set(&value_, 1);
40  }
41
42  // Destructor.
43  ~gcc_sync_fenced_block()
44  {
45    __sync_lock_release(&value_);
46  }
47
48private:
49  int value_;
50};
51
52} // namespace detail
53} // namespace asio
54} // namespace boost
55
56#include <boost/asio/detail/pop_options.hpp>
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 // BOOST_ASIO_DETAIL_GCC_SYNC_FENCED_BLOCK_HPP