]> git.lyx.org Git - features.git/blobdiff - boost/boost/smart_ptr/detail/atomic_count.hpp
boost: add eol property
[features.git] / boost / boost / smart_ptr / detail / atomic_count.hpp
index f8561371fa23b6c1e03d5da45914b7ccf0c8575e..cc44ac2f96d815a0581b93115f71e22c0d8dfa7d 100644 (file)
-#ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_HPP_INCLUDED\r
-#define BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_HPP_INCLUDED\r
-\r
-// MS compatible compilers support #pragma once\r
-\r
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)\r
-# pragma once\r
-#endif\r
-\r
-//\r
-//  boost/detail/atomic_count.hpp - thread/SMP safe reference counter\r
-//\r
-//  Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.\r
-//\r
-// Distributed under the Boost Software License, Version 1.0. (See\r
-// accompanying file LICENSE_1_0.txt or copy at\r
-// http://www.boost.org/LICENSE_1_0.txt)\r
-//\r
-//  typedef <implementation-defined> boost::detail::atomic_count;\r
-//\r
-//  atomic_count a(n);\r
-//\r
-//    (n is convertible to long)\r
-//\r
-//    Effects: Constructs an atomic_count with an initial value of n\r
-//\r
-//  a;\r
-//\r
-//    Returns: (long) the current value of a\r
-//\r
-//  ++a;\r
-//\r
-//    Effects: Atomically increments the value of a\r
-//    Returns: (long) the new value of a\r
-//\r
-//  --a;\r
-//\r
-//    Effects: Atomically decrements the value of a\r
-//    Returns: (long) the new value of a\r
-//\r
-//    Important note: when --a returns zero, it must act as a\r
-//      read memory barrier (RMB); i.e. the calling thread must\r
-//      have a synchronized view of the memory\r
-//\r
-//    On Intel IA-32 (x86) memory is always synchronized, so this\r
-//      is not a problem.\r
-//\r
-//    On many architectures the atomic instructions already act as\r
-//      a memory barrier.\r
-//\r
-//    This property is necessary for proper reference counting, since\r
-//      a thread can update the contents of a shared object, then\r
-//      release its reference, and another thread may immediately\r
-//      release the last reference causing object destruction.\r
-//\r
-//    The destructor needs to have a synchronized view of the\r
-//      object to perform proper cleanup.\r
-//\r
-//    Original example by Alexander Terekhov:\r
-//\r
-//    Given:\r
-//\r
-//    - a mutable shared object OBJ;\r
-//    - two threads THREAD1 and THREAD2 each holding \r
-//      a private smart_ptr object pointing to that OBJ.\r
-//\r
-//    t1: THREAD1 updates OBJ (thread-safe via some synchronization)\r
-//      and a few cycles later (after "unlock") destroys smart_ptr;\r
-//\r
-//    t2: THREAD2 destroys smart_ptr WITHOUT doing any synchronization \r
-//      with respect to shared mutable object OBJ; OBJ destructors\r
-//      are called driven by smart_ptr interface...\r
-//\r
-\r
-#include <boost/config.hpp>\r
-#include <boost/smart_ptr/detail/sp_has_sync.hpp>\r
-\r
-#ifndef BOOST_HAS_THREADS\r
-\r
-namespace boost\r
-{\r
-\r
-namespace detail\r
-{\r
-\r
-typedef long atomic_count;\r
-\r
-}\r
-\r
-}\r
-\r
-#elif defined(BOOST_AC_USE_PTHREADS)\r
-#  include <boost/smart_ptr/detail/atomic_count_pthreads.hpp>\r
-\r
-#elif defined( __GNUC__ ) && ( defined( __i386__ ) || defined( __x86_64__ ) )\r
-#  include <boost/smart_ptr/detail/atomic_count_gcc_x86.hpp>\r
-\r
-#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)\r
-#  include <boost/smart_ptr/detail/atomic_count_win32.hpp>\r
-\r
-#elif defined( BOOST_SP_HAS_SYNC )\r
-#  include <boost/smart_ptr/detail/atomic_count_sync.hpp>\r
-\r
-#elif defined(__GLIBCPP__) || defined(__GLIBCXX__)\r
-#  include <boost/smart_ptr/detail/atomic_count_gcc.hpp>\r
-\r
-#elif defined(BOOST_HAS_PTHREADS)\r
-\r
-#  define BOOST_AC_USE_PTHREADS\r
-#  include <boost/smart_ptr/detail/atomic_count_pthreads.hpp>\r
-\r
-#else\r
-\r
-// Use #define BOOST_DISABLE_THREADS to avoid the error\r
-#error Unrecognized threading platform\r
-\r
-#endif\r
-\r
-#endif // #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_HPP_INCLUDED\r
+#ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_HPP_INCLUDED
+#define BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_HPP_INCLUDED
+
+// MS compatible compilers support #pragma once
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+//
+//  boost/detail/atomic_count.hpp - thread/SMP safe reference counter
+//
+//  Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+//  typedef <implementation-defined> boost::detail::atomic_count;
+//
+//  atomic_count a(n);
+//
+//    (n is convertible to long)
+//
+//    Effects: Constructs an atomic_count with an initial value of n
+//
+//  a;
+//
+//    Returns: (long) the current value of a
+//
+//  ++a;
+//
+//    Effects: Atomically increments the value of a
+//    Returns: (long) the new value of a
+//
+//  --a;
+//
+//    Effects: Atomically decrements the value of a
+//    Returns: (long) the new value of a
+//
+//    Important note: when --a returns zero, it must act as a
+//      read memory barrier (RMB); i.e. the calling thread must
+//      have a synchronized view of the memory
+//
+//    On Intel IA-32 (x86) memory is always synchronized, so this
+//      is not a problem.
+//
+//    On many architectures the atomic instructions already act as
+//      a memory barrier.
+//
+//    This property is necessary for proper reference counting, since
+//      a thread can update the contents of a shared object, then
+//      release its reference, and another thread may immediately
+//      release the last reference causing object destruction.
+//
+//    The destructor needs to have a synchronized view of the
+//      object to perform proper cleanup.
+//
+//    Original example by Alexander Terekhov:
+//
+//    Given:
+//
+//    - a mutable shared object OBJ;
+//    - two threads THREAD1 and THREAD2 each holding 
+//      a private smart_ptr object pointing to that OBJ.
+//
+//    t1: THREAD1 updates OBJ (thread-safe via some synchronization)
+//      and a few cycles later (after "unlock") destroys smart_ptr;
+//
+//    t2: THREAD2 destroys smart_ptr WITHOUT doing any synchronization 
+//      with respect to shared mutable object OBJ; OBJ destructors
+//      are called driven by smart_ptr interface...
+//
+
+#include <boost/config.hpp>
+#include <boost/smart_ptr/detail/sp_has_sync.hpp>
+
+#ifndef BOOST_HAS_THREADS
+
+namespace boost
+{
+
+namespace detail
+{
+
+typedef long atomic_count;
+
+}
+
+}
+
+#elif defined(BOOST_AC_USE_PTHREADS)
+#  include <boost/smart_ptr/detail/atomic_count_pthreads.hpp>
+
+#elif defined( __GNUC__ ) && ( defined( __i386__ ) || defined( __x86_64__ ) )
+#  include <boost/smart_ptr/detail/atomic_count_gcc_x86.hpp>
+
+#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+#  include <boost/smart_ptr/detail/atomic_count_win32.hpp>
+
+#elif defined( BOOST_SP_HAS_SYNC )
+#  include <boost/smart_ptr/detail/atomic_count_sync.hpp>
+
+#elif defined(__GLIBCPP__) || defined(__GLIBCXX__)
+#  include <boost/smart_ptr/detail/atomic_count_gcc.hpp>
+
+#elif defined(BOOST_HAS_PTHREADS)
+
+#  define BOOST_AC_USE_PTHREADS
+#  include <boost/smart_ptr/detail/atomic_count_pthreads.hpp>
+
+#else
+
+// Use #define BOOST_DISABLE_THREADS to avoid the error
+#error Unrecognized threading platform
+
+#endif
+
+#endif // #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_HPP_INCLUDED