$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
From: chris_at_[hidden]
Date: 2008-05-01 18:27:21
Author: chris_kohlhoff
Date: 2008-05-01 18:27:21 EDT (Thu, 01 May 2008)
New Revision: 44998
URL: http://svn.boost.org/trac/boost/changeset/44998
Log:
A memory barrier is needed on some platforms to ensure that all updates
to the node occur before the tail pointer is updated.
Text files modified: 
   trunk/boost/asio/detail/indirect_handler_queue.hpp |    18 ++++++++++++++++++                      
   1 files changed, 18 insertions(+), 0 deletions(-)
Modified: trunk/boost/asio/detail/indirect_handler_queue.hpp
==============================================================================
--- trunk/boost/asio/detail/indirect_handler_queue.hpp	(original)
+++ trunk/boost/asio/detail/indirect_handler_queue.hpp	2008-05-01 18:27:21 EDT (Thu, 01 May 2008)
@@ -21,6 +21,11 @@
 #include <boost/asio/detail/handler_invoke_helpers.hpp>
 #include <boost/asio/detail/noncopyable.hpp>
 
+#if defined(_MSC_VER) && (_MSC_VER >= 1310)
+extern "C" void _ReadWriteBarrier();
+# pragma intrinsic(_ReadWriteBarrier)
+#endif // defined(_MSC_VER) && (_MSC_VER >= 1310)
+
 namespace boost {
 namespace asio {
 namespace detail {
@@ -195,6 +200,7 @@
     next_version_ += 2;
     n->handler_ = h;
     n->next_ = 0;
+    memory_barrier();
     back_->next_ = n;
     back_ = n;
   }
@@ -246,6 +252,18 @@
     Handler handler_;
   };
 
+  // Helper function to create a memory barrier.
+  static void memory_barrier()
+  {
+#if defined(_GLIBCXX_WRITE_MEM_BARRIER)
+    _GLIBCXX_WRITE_MEM_BARRIER;
+#elif defined(_MSC_VER) && (_MSC_VER >= 1310)
+    _ReadWriteBarrier();
+#else
+# error memory barrier required
+#endif
+  }
+
   // The front of the queue.
   node* front_;