PageRenderTime 39ms CodeModel.GetById 29ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://hadesmem.googlecode.com/
C++ Header | 81 lines | 57 code | 13 blank | 11 comment | 8 complexity | 07c857fc492c3b370755ed0d4489431e MD5 | raw file
 1//
 2// detail/win_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_WIN_FENCED_BLOCK_HPP
12#define BOOST_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 <boost/asio/detail/config.hpp>
19
20#if defined(BOOST_WINDOWS) && !defined(UNDER_CE)
21
22#include <boost/asio/detail/socket_types.hpp>
23
24#include <boost/asio/detail/push_options.hpp>
25
26namespace boost {
27namespace asio {
28namespace detail {
29
30class win_fenced_block
31  : private noncopyable
32{
33public:
34  // Constructor.
35  win_fenced_block()
36  {
37#if defined(__BORLANDC__)
38    LONG barrier = 0;
39    ::InterlockedExchange(&barrier, 1);
40#elif defined(BOOST_MSVC) && ((BOOST_MSVC < 1400) || !defined(MemoryBarrier))
41# if defined(_M_IX86)
42#  pragma warning(push)
43#  pragma warning(disable:4793)
44    LONG barrier;
45    __asm { xchg barrier, eax }
46#  pragma warning(pop)
47# endif // defined(_M_IX86)
48#else
49    MemoryBarrier();
50#endif
51  }
52
53  // Destructor.
54  ~win_fenced_block()
55  {
56#if defined(__BORLANDC__)
57    LONG barrier = 0;
58    ::InterlockedExchange(&barrier, 1);
59#elif defined(BOOST_MSVC) && ((BOOST_MSVC < 1400) || !defined(MemoryBarrier))
60# if defined(_M_IX86)
61#  pragma warning(push)
62#  pragma warning(disable:4793)
63    LONG barrier;
64    __asm { xchg barrier, eax }
65#  pragma warning(pop)
66# endif // defined(_M_IX86)
67#else
68    MemoryBarrier();
69#endif
70  }
71};
72
73} // namespace detail
74} // namespace asio
75} // namespace boost
76
77#include <boost/asio/detail/pop_options.hpp>
78
79#endif // defined(BOOST_WINDOWS) && !defined(UNDER_CE)
80
81#endif // BOOST_ASIO_DETAIL_WIN_FENCED_BLOCK_HPP