Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r63682 - in branches/release: . boost boost/algorithm/string boost/archive boost/asio boost/asio/detail boost/asio/detail/impl boost/asio/impl boost/bimap boost/config boost/detail boost/filesystem boost/functional/hash boost/fusion boost/gil boost/graph boost/integer boost/interprocess boost/intrusive boost/math boost/msm boost/numeric/ublas boost/program_options boost/property_tree boost/python boost/range boost/regex boost/serialization boost/signals boost/signals2 boost/spirit boost/spirit/home boost/spirit/home/karma boost/spirit/home/support boost/statechart boost/system boost/thread boost/tr1 boost/type_traits boost/unordered boost/utility boost/uuid boost/variant boost/wave doc libs libs/array/doc libs/array/test libs/asio/doc libs/asio/example/http/server4 libs/asio/example/timeouts libs/asio/test libs/bimap libs/config libs/config/test libs/filesystem libs/functional/hash libs/fusion libs/graph_parallel libs/integer libs/interprocess libs/intrusive libs/math libs/mpl/doc/refmanual libs/mpl/doc/src/refmanual libs/msm libs/numeric/ublas libs/numeric/ublas/doc libs/program_options libs/property_tree libs/python libs/python/doc/v2 libs/range libs/range/doc libs/regex libs/serialization libs/signals libs/signals2 libs/spirit libs/spirit/classic/example libs/spirit/doc libs/spirit/example libs/spirit/phoenix libs/spirit/test libs/spirit/test/qi libs/statechart libs/static_assert libs/system libs/thread libs/timer libs/tr1 libs/type_traits libs/unordered libs/utility libs/utility/swap/test libs/uuid libs/wave more more/getting_started status tools tools/bcp tools/build/v2 tools/build/v2/tools tools/inspect tools/jam tools/quickbook tools/regression tools/release tools/wave
From: chris_at_[hidden]
Date: 2010-07-06 00:50:01


Author: chris_kohlhoff
Date: 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
New Revision: 63682
URL: http://svn.boost.org/trac/boost/changeset/63682

Log:
Merged from trunk.

........
  r63568 | chris_kohlhoff | 2010-07-04 16:49:18 +1000 (Sun, 04 Jul 2010) | 2 lines
  
  Fix coroutine macros to work with MSVC's edit-and-continue debug settings.
........
  r63569 | chris_kohlhoff | 2010-07-04 16:53:57 +1000 (Sun, 04 Jul 2010) | 2 lines
  
  Reworked timeout examples.
........
  r63570 | chris_kohlhoff | 2010-07-04 16:57:32 +1000 (Sun, 04 Jul 2010) | 2 lines
  
  Ensure arguments to handlers are passed as const types.
........
  r63571 | chris_kohlhoff | 2010-07-04 17:19:30 +1000 (Sun, 04 Jul 2010) | 2 lines
  
  Fences for arm.
........
  r63572 | chris_kohlhoff | 2010-07-04 17:20:18 +1000 (Sun, 04 Jul 2010) | 2 lines
  
  Fences for arm.
........
  r63573 | chris_kohlhoff | 2010-07-04 17:21:24 +1000 (Sun, 04 Jul 2010) | 2 lines
  
  Fix forward declaration.
........
  r63574 | chris_kohlhoff | 2010-07-04 17:23:27 +1000 (Sun, 04 Jul 2010) | 2 lines
  
  Add cancellation of reactor operations.
........
  r63575 | chris_kohlhoff | 2010-07-04 17:26:36 +1000 (Sun, 04 Jul 2010) | 2 lines
  
  Fixes in non_blocking_read.
........
  r63576 | chris_kohlhoff | 2010-07-04 17:28:20 +1000 (Sun, 04 Jul 2010) | 2 lines
  
  Make more tolerant of different platform sdk variants.
........
  r63577 | chris_kohlhoff | 2010-07-04 17:37:42 +1000 (Sun, 04 Jul 2010) | 2 lines
  
  Eliminate unnecessary uses of hash_map.
........
  r63578 | chris_kohlhoff | 2010-07-04 17:43:23 +1000 (Sun, 04 Jul 2010) | 2 lines
  
  Point docs at new timeout examples.
........
  r63592 | chris_kohlhoff | 2010-07-04 23:11:14 +1000 (Sun, 04 Jul 2010) | 2 lines
  
  Add missing operator+ overload. Fixes #4382.
........
  r63594 | chris_kohlhoff | 2010-07-04 23:42:41 +1000 (Sun, 04 Jul 2010) | 2 lines
  
  Fix unused parameters.
........
  r63646 | chris_kohlhoff | 2010-07-05 17:43:22 +1000 (Mon, 05 Jul 2010) | 2 lines
  
  Add missing parameter.
........

Added:
   branches/release/boost/asio/detail/gcc_arm_fenced_block.hpp
      - copied unchanged from r63578, /trunk/boost/asio/detail/gcc_arm_fenced_block.hpp
   branches/release/boost/asio/detail/object_pool.hpp
      - copied unchanged from r63578, /trunk/boost/asio/detail/object_pool.hpp
   branches/release/libs/asio/example/timeouts/async_tcp_client.cpp
      - copied unchanged from r63578, /trunk/libs/asio/example/timeouts/async_tcp_client.cpp
   branches/release/libs/asio/example/timeouts/blocking_tcp_client.cpp
      - copied unchanged from r63578, /trunk/libs/asio/example/timeouts/blocking_tcp_client.cpp
   branches/release/libs/asio/example/timeouts/blocking_udp_client.cpp
      - copied unchanged from r63578, /trunk/libs/asio/example/timeouts/blocking_udp_client.cpp
   branches/release/libs/asio/example/timeouts/server.cpp
      - copied unchanged from r63578, /trunk/libs/asio/example/timeouts/server.cpp
Removed:
   branches/release/libs/asio/example/timeouts/accept_timeout.cpp
   branches/release/libs/asio/example/timeouts/connect_timeout.cpp
   branches/release/libs/asio/example/timeouts/datagram_receive_timeout.cpp
   branches/release/libs/asio/example/timeouts/stream_receive_timeout.cpp
Properties modified:
   branches/release/ (props changed)
   branches/release/INSTALL (props changed)
   branches/release/Jamroot (props changed)
   branches/release/LICENSE_1_0.txt (props changed)
   branches/release/boost/ (props changed)
   branches/release/boost-build.jam (props changed)
   branches/release/boost.css (props changed)
   branches/release/boost.png (props changed)
   branches/release/boost/algorithm/string/ (props changed)
   branches/release/boost/archive/ (props changed)
   branches/release/boost/array.hpp (props changed)
   branches/release/boost/bimap/ (props changed)
   branches/release/boost/config/ (props changed)
   branches/release/boost/config.hpp (props changed)
   branches/release/boost/detail/ (props changed)
   branches/release/boost/detail/endian.hpp (props changed)
   branches/release/boost/filesystem/ (props changed)
   branches/release/boost/functional/hash/ (props changed)
   branches/release/boost/fusion/ (props changed)
   branches/release/boost/gil/ (props changed)
   branches/release/boost/graph/ (props changed)
   branches/release/boost/integer/ (props changed)
   branches/release/boost/interprocess/ (props changed)
   branches/release/boost/intrusive/ (props changed)
   branches/release/boost/math/ (props changed)
   branches/release/boost/math_fwd.hpp (props changed)
   branches/release/boost/msm/ (props changed)
   branches/release/boost/numeric/ublas/ (props changed)
   branches/release/boost/numeric/ublas/functional.hpp (props changed)
   branches/release/boost/program_options/ (props changed)
   branches/release/boost/property_tree/ (props changed)
   branches/release/boost/python/ (props changed)
   branches/release/boost/range/ (props changed)
   branches/release/boost/regex/ (props changed)
   branches/release/boost/serialization/ (props changed)
   branches/release/boost/serialization/factory.hpp (props changed)
   branches/release/boost/signals/ (props changed)
   branches/release/boost/signals2/ (props changed)
   branches/release/boost/spirit/ (props changed)
   branches/release/boost/spirit/home/ (props changed)
   branches/release/boost/spirit/home/karma/ (props changed)
   branches/release/boost/spirit/home/support/attributes.hpp (props changed)
   branches/release/boost/statechart/ (props changed)
   branches/release/boost/system/ (props changed)
   branches/release/boost/thread/ (props changed)
   branches/release/boost/thread.hpp (props changed)
   branches/release/boost/tr1/ (props changed)
   branches/release/boost/type_traits/ (props changed)
   branches/release/boost/unordered/ (props changed)
   branches/release/boost/utility/ (props changed)
   branches/release/boost/utility/value_init.hpp (props changed)
   branches/release/boost/uuid/ (props changed)
   branches/release/boost/variant/ (props changed)
   branches/release/boost/version.hpp (props changed)
   branches/release/boost/wave/ (props changed)
   branches/release/bootstrap.bat (props changed)
   branches/release/bootstrap.sh (props changed)
   branches/release/doc/ (props changed)
   branches/release/index.htm (props changed)
   branches/release/index.html (props changed)
   branches/release/libs/ (props changed)
   branches/release/libs/array/doc/array.xml (props changed)
   branches/release/libs/array/test/array0.cpp (props changed)
   branches/release/libs/array/test/array2.cpp (props changed)
   branches/release/libs/bimap/ (props changed)
   branches/release/libs/config/ (props changed)
   branches/release/libs/config/test/boost_no_com_value_init.ipp (props changed)
   branches/release/libs/filesystem/ (props changed)
   branches/release/libs/functional/hash/ (props changed)
   branches/release/libs/fusion/ (props changed)
   branches/release/libs/graph_parallel/ (props changed)
   branches/release/libs/integer/ (props changed)
   branches/release/libs/interprocess/ (props changed)
   branches/release/libs/intrusive/ (props changed)
   branches/release/libs/libraries.htm (props changed)
   branches/release/libs/maintainers.txt (props changed)
   branches/release/libs/math/ (props changed)
   branches/release/libs/mpl/doc/refmanual/broken-compiler-workarounds.html (props changed)
   branches/release/libs/mpl/doc/refmanual/categorized-index-concepts.html (props changed)
   branches/release/libs/mpl/doc/refmanual/cfg-no-preprocessed-headers.html (props changed)
   branches/release/libs/mpl/doc/refmanual/composition-and-argument-binding.html (props changed)
   branches/release/libs/mpl/doc/refmanual/data-types-concepts.html (props changed)
   branches/release/libs/mpl/doc/refmanual/data-types-miscellaneous.html (props changed)
   branches/release/libs/mpl/doc/refmanual/extensible-associative-sequence.html (props changed)
   branches/release/libs/mpl/doc/refmanual/inserter-class.html (props changed)
   branches/release/libs/mpl/doc/refmanual/tag-dispatched-metafunction.html (props changed)
   branches/release/libs/mpl/doc/refmanual/trivial-metafunctions-summary.html (props changed)
   branches/release/libs/mpl/doc/src/refmanual/Iterators-Iterator.rst (props changed)
   branches/release/libs/msm/ (props changed)
   branches/release/libs/numeric/ublas/ (props changed)
   branches/release/libs/numeric/ublas/doc/ (props changed)
   branches/release/libs/program_options/ (props changed)
   branches/release/libs/property_tree/ (props changed)
   branches/release/libs/python/ (props changed)
   branches/release/libs/python/doc/v2/args.html (props changed)
   branches/release/libs/python/doc/v2/return_internal_reference.html (props changed)
   branches/release/libs/range/ (props changed)
   branches/release/libs/range/doc/ (props changed)
   branches/release/libs/regex/ (props changed)
   branches/release/libs/serialization/ (props changed)
   branches/release/libs/signals/ (props changed)
   branches/release/libs/signals2/ (props changed)
   branches/release/libs/spirit/ (props changed)
   branches/release/libs/spirit/classic/example/ (props changed)
   branches/release/libs/spirit/doc/ (props changed)
   branches/release/libs/spirit/example/ (props changed)
   branches/release/libs/spirit/phoenix/ (props changed)
   branches/release/libs/spirit/test/ (props changed)
   branches/release/libs/spirit/test/qi/optional.cpp (props changed)
   branches/release/libs/statechart/ (props changed)
   branches/release/libs/static_assert/ (props changed)
   branches/release/libs/system/ (props changed)
   branches/release/libs/thread/ (props changed)
   branches/release/libs/timer/ (props changed)
   branches/release/libs/tr1/ (props changed)
   branches/release/libs/type_traits/ (props changed)
   branches/release/libs/unordered/ (props changed)
   branches/release/libs/utility/ (props changed)
   branches/release/libs/utility/swap.html (props changed)
   branches/release/libs/utility/swap/test/std_bitset.cpp (props changed)
   branches/release/libs/utility/value_init.htm (props changed)
   branches/release/libs/utility/value_init_test.cpp (props changed)
   branches/release/libs/uuid/ (props changed)
   branches/release/libs/wave/ (props changed)
   branches/release/more/ (props changed)
   branches/release/more/getting_started/ (props changed)
   branches/release/rst.css (props changed)
   branches/release/status/ (props changed)
   branches/release/status/Jamfile.v2 (props changed)
   branches/release/tools/ (props changed)
   branches/release/tools/bcp/ (props changed)
   branches/release/tools/build/v2/ (props changed)
   branches/release/tools/build/v2/tools/ (props changed)
   branches/release/tools/inspect/ (props changed)
   branches/release/tools/jam/ (props changed)
   branches/release/tools/quickbook/ (props changed)
   branches/release/tools/regression/ (props changed)
   branches/release/tools/release/ (props changed)
   branches/release/tools/wave/ (props changed)
Text files modified:
   branches/release/boost/asio/buffers_iterator.hpp | 9 +
   branches/release/boost/asio/detail/bind_handler.hpp | 20 +++-
   branches/release/boost/asio/detail/deadline_timer_service.hpp | 5
   branches/release/boost/asio/detail/dev_poll_reactor.hpp | 6
   branches/release/boost/asio/detail/epoll_reactor.hpp | 31 ++---
   branches/release/boost/asio/detail/fenced_block.hpp | 12 ++
   branches/release/boost/asio/detail/gcc_fenced_block.hpp | 6 +
   branches/release/boost/asio/detail/impl/descriptor_ops.ipp | 4
   branches/release/boost/asio/detail/impl/dev_poll_reactor.hpp | 23 ++-
   branches/release/boost/asio/detail/impl/dev_poll_reactor.ipp | 3
   branches/release/boost/asio/detail/impl/epoll_reactor.hpp | 23 ++-
   branches/release/boost/asio/detail/impl/epoll_reactor.ipp | 69 ++++++++-----
   branches/release/boost/asio/detail/impl/kqueue_reactor.hpp | 23 ++-
   branches/release/boost/asio/detail/impl/kqueue_reactor.ipp | 67 ++++++++-----
   branches/release/boost/asio/detail/impl/select_reactor.hpp | 23 ++-
   branches/release/boost/asio/detail/impl/select_reactor.ipp | 14 +-
   branches/release/boost/asio/detail/impl/timer_queue.ipp | 8
   branches/release/boost/asio/detail/impl/win_iocp_io_service.hpp | 14 +-
   branches/release/boost/asio/detail/impl/win_iocp_socket_service_base.ipp | 10 ++
   branches/release/boost/asio/detail/kqueue_reactor.hpp | 27 ++---
   branches/release/boost/asio/detail/regex_fwd.hpp | 2
   branches/release/boost/asio/detail/select_reactor.hpp | 6
   branches/release/boost/asio/detail/timer_queue.hpp | 200 +++++++++++++++++++++++----------------
   branches/release/boost/asio/detail/win_fenced_block.hpp | 26 ++--
   branches/release/boost/asio/detail/win_iocp_io_service.hpp | 8 +
   branches/release/boost/asio/impl/read.hpp | 6
   branches/release/boost/asio/impl/read_at.hpp | 6
   branches/release/boost/asio/impl/write.hpp | 8
   branches/release/boost/asio/impl/write_at.hpp | 8
   branches/release/libs/asio/doc/examples.qbk | 8
   branches/release/libs/asio/doc/reference.qbk | 42 ++++++++
   branches/release/libs/asio/example/http/server4/coroutine.hpp | 22 +++-
   branches/release/libs/asio/example/timeouts/Jamfile | 16 +-
   branches/release/libs/asio/example/timeouts/Jamfile.v2 | 8
   branches/release/libs/asio/test/buffers_iterator.cpp | 39 +++++++
   35 files changed, 512 insertions(+), 290 deletions(-)

Modified: branches/release/boost/asio/buffers_iterator.hpp
==============================================================================
--- branches/release/boost/asio/buffers_iterator.hpp (original)
+++ branches/release/boost/asio/buffers_iterator.hpp 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
@@ -208,6 +208,15 @@
     return tmp;
   }
 
+ /// Addition operator.
+ friend buffers_iterator operator+(std::ptrdiff_t difference,
+ const buffers_iterator& iter)
+ {
+ buffers_iterator tmp(iter);
+ tmp.advance(difference);
+ return tmp;
+ }
+
   /// Subtraction operator.
   friend buffers_iterator operator-(const buffers_iterator& iter,
       std::ptrdiff_t difference)

Modified: branches/release/boost/asio/detail/bind_handler.hpp
==============================================================================
--- branches/release/boost/asio/detail/bind_handler.hpp (original)
+++ branches/release/boost/asio/detail/bind_handler.hpp 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
@@ -37,7 +37,7 @@
 
   void operator()()
   {
- handler_(arg1_);
+ handler_(static_cast<const Arg1&>(arg1_));
   }
 
   void operator()() const
@@ -94,7 +94,8 @@
 
   void operator()()
   {
- handler_(arg1_, arg2_);
+ handler_(static_cast<const Arg1&>(arg1_),
+ static_cast<const Arg2&>(arg2_));
   }
 
   void operator()() const
@@ -154,7 +155,9 @@
 
   void operator()()
   {
- handler_(arg1_, arg2_, arg3_);
+ handler_(static_cast<const Arg1&>(arg1_),
+ static_cast<const Arg2&>(arg2_),
+ static_cast<const Arg3&>(arg3_));
   }
 
   void operator()() const
@@ -218,7 +221,10 @@
 
   void operator()()
   {
- handler_(arg1_, arg2_, arg3_, arg4_);
+ handler_(static_cast<const Arg1&>(arg1_),
+ static_cast<const Arg2&>(arg2_),
+ static_cast<const Arg3&>(arg3_),
+ static_cast<const Arg4&>(arg4_));
   }
 
   void operator()() const
@@ -289,7 +295,11 @@
 
   void operator()()
   {
- handler_(arg1_, arg2_, arg3_, arg4_, arg5_);
+ handler_(static_cast<const Arg1&>(arg1_),
+ static_cast<const Arg2&>(arg2_),
+ static_cast<const Arg3&>(arg3_),
+ static_cast<const Arg4&>(arg4_),
+ static_cast<const Arg5&>(arg5_));
   }
 
   void operator()() const

Modified: branches/release/boost/asio/detail/deadline_timer_service.hpp
==============================================================================
--- branches/release/boost/asio/detail/deadline_timer_service.hpp (original)
+++ branches/release/boost/asio/detail/deadline_timer_service.hpp 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
@@ -56,6 +56,7 @@
   {
     time_type expiry;
     bool might_have_pending_waits;
+ typename timer_queue<Time_Traits>::per_timer_data timer_data;
   };
 
   // Constructor.
@@ -99,7 +100,7 @@
       ec = boost::system::error_code();
       return 0;
     }
- std::size_t count = scheduler_.cancel_timer(timer_queue_, &impl);
+ std::size_t count = scheduler_.cancel_timer(timer_queue_, impl.timer_data);
     impl.might_have_pending_waits = false;
     ec = boost::system::error_code();
     return count;
@@ -166,7 +167,7 @@
 
     impl.might_have_pending_waits = true;
 
- scheduler_.schedule_timer(timer_queue_, impl.expiry, p.p, &impl);
+ scheduler_.schedule_timer(timer_queue_, impl.expiry, impl.timer_data, p.p);
     p.v = p.p = 0;
   }
 

Modified: branches/release/boost/asio/detail/dev_poll_reactor.hpp
==============================================================================
--- branches/release/boost/asio/detail/dev_poll_reactor.hpp (original)
+++ branches/release/boost/asio/detail/dev_poll_reactor.hpp 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
@@ -103,12 +103,14 @@
   // specified absolute time.
   template <typename Time_Traits>
   void schedule_timer(timer_queue<Time_Traits>& queue,
- const typename Time_Traits::time_type& time, timer_op* op, void* token);
+ const typename Time_Traits::time_type& time,
+ typename timer_queue<Time_Traits>::per_timer_data& timer, timer_op* op);
 
   // Cancel the timer operations associated with the given token. Returns the
   // number of operations that have been posted or dispatched.
   template <typename Time_Traits>
- std::size_t cancel_timer(timer_queue<Time_Traits>& queue, void* token);
+ std::size_t cancel_timer(timer_queue<Time_Traits>& queue,
+ typename timer_queue<Time_Traits>::per_timer_data& timer);
 
   // Run /dev/poll once until interrupted or events are ready to be dispatched.
   BOOST_ASIO_DECL void run(bool block, op_queue<operation>& ops);

Modified: branches/release/boost/asio/detail/epoll_reactor.hpp
==============================================================================
--- branches/release/boost/asio/detail/epoll_reactor.hpp (original)
+++ branches/release/boost/asio/detail/epoll_reactor.hpp 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
@@ -21,8 +21,8 @@
 
 #include <boost/asio/io_service.hpp>
 #include <boost/asio/detail/epoll_reactor_fwd.hpp>
-#include <boost/asio/detail/hash_map.hpp>
 #include <boost/asio/detail/mutex.hpp>
+#include <boost/asio/detail/object_pool.hpp>
 #include <boost/asio/detail/op_queue.hpp>
 #include <boost/asio/detail/reactor_op.hpp>
 #include <boost/asio/detail/select_interrupter.hpp>
@@ -46,15 +46,15 @@
     connect_op = 1, except_op = 2, max_ops = 3 };
 
   // Per-descriptor queues.
- struct descriptor_state
+ class descriptor_state
   {
- descriptor_state() {}
- descriptor_state(const descriptor_state&) {}
- void operator=(const descriptor_state&) {}
-
+ friend class epoll_reactor;
+ friend class object_pool_access;
     mutex mutex_;
     op_queue<reactor_op> op_queue_[max_ops];
     bool shutdown_;
+ descriptor_state* next_;
+ descriptor_state* prev_;
   };
 
   // Per-descriptor data.
@@ -111,13 +111,15 @@
   // Schedule a new operation in the given timer queue to expire at the
   // specified absolute time.
   template <typename Time_Traits>
- void schedule_timer(timer_queue<Time_Traits>& timer_queue,
- const typename Time_Traits::time_type& time, timer_op* op, void* token);
+ void schedule_timer(timer_queue<Time_Traits>& queue,
+ const typename Time_Traits::time_type& time,
+ typename timer_queue<Time_Traits>::per_timer_data& timer, timer_op* op);
 
   // Cancel the timer operations associated with the given token. Returns the
   // number of operations that have been posted or dispatched.
   template <typename Time_Traits>
- std::size_t cancel_timer(timer_queue<Time_Traits>& timer_queue, void* token);
+ std::size_t cancel_timer(timer_queue<Time_Traits>& queue,
+ typename timer_queue<Time_Traits>::per_timer_data& timer);
 
   // Run epoll once until interrupted or events are ready to be dispatched.
   BOOST_ASIO_DECL void run(bool block, op_queue<operation>& ops);
@@ -177,15 +179,8 @@
   // Mutex to protect access to the registered descriptors.
   mutex registered_descriptors_mutex_;
 
- // Keep track of all registered descriptors. This code relies on the fact that
- // the hash_map implementation pools deleted nodes, meaning that we can assume
- // our descriptor_state pointer remains valid even after the entry is removed.
- // Technically this is not true for C++98, as that standard says that spliced
- // elements in a list are invalidated. However, C++0x fixes this shortcoming
- // so we'll just assume that C++98 std::list implementations will do the right
- // thing anyway.
- typedef detail::hash_map<socket_type, descriptor_state> descriptor_map;
- descriptor_map registered_descriptors_;
+ // Keep track of all registered descriptors.
+ object_pool<descriptor_state> registered_descriptors_;
 };
 
 } // namespace detail

Modified: branches/release/boost/asio/detail/fenced_block.hpp
==============================================================================
--- branches/release/boost/asio/detail/fenced_block.hpp (original)
+++ branches/release/boost/asio/detail/fenced_block.hpp 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
@@ -26,10 +26,14 @@
 #elif defined(__GNUC__) \
   && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4)) \
   && !defined(__INTEL_COMPILER) && !defined(__ICL) \
- && !defined(__ICC) && !defined(__ECC) && !defined(__PATHSCALE__)
+ && !defined(__ICC) && !defined(__ECC) && !defined(__PATHSCALE__) \
+ && (!defined(__arm__) || (defined(__arm__) && \
+ (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) || (__GNUC__ > 4)))
 # include <boost/asio/detail/gcc_fenced_block.hpp>
 #elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
 # include <boost/asio/detail/gcc_x86_fenced_block.hpp>
+#elif defined(__GNUC__) && defined(__arm__)
+# include <boost/asio/detail/gcc_arm_fenced_block.hpp>
 #elif defined(BOOST_WINDOWS) && !defined(UNDER_CE)
 # include <boost/asio/detail/win_fenced_block.hpp>
 #else
@@ -49,10 +53,14 @@
 #elif defined(__GNUC__) \
   && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4)) \
   && !defined(__INTEL_COMPILER) && !defined(__ICL) \
- && !defined(__ICC) && !defined(__ECC) && !defined(__PATHSCALE__)
+ && !defined(__ICC) && !defined(__ECC) && !defined(__PATHSCALE__) \
+ && (!defined(__arm__) || (defined(__arm__) && \
+ (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) || (__GNUC__ > 4)))
 typedef gcc_fenced_block fenced_block;
 #elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
 typedef gcc_x86_fenced_block fenced_block;
+#elif defined(__GNUC__) && defined(__arm__)
+typedef gcc_arm_fenced_block fenced_block;
 #elif defined(BOOST_WINDOWS) && !defined(UNDER_CE)
 typedef win_fenced_block fenced_block;
 #else

Modified: branches/release/boost/asio/detail/gcc_fenced_block.hpp
==============================================================================
--- branches/release/boost/asio/detail/gcc_fenced_block.hpp (original)
+++ branches/release/boost/asio/detail/gcc_fenced_block.hpp 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
@@ -20,7 +20,9 @@
 #if defined(__GNUC__) \
   && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4)) \
   && !defined(__INTEL_COMPILER) && !defined(__ICL) \
- && !defined(__ICC) && !defined(__ECC) && !defined(__PATHSCALE__)
+ && !defined(__ICC) && !defined(__ECC) && !defined(__PATHSCALE__) \
+ && (!defined(__arm__) || (defined(__arm__) && \
+ (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) || (__GNUC__ > 4)))
 
 #include <boost/asio/detail/push_options.hpp>
 
@@ -59,5 +61,7 @@
        // && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4))
        // && !defined(__INTEL_COMPILER) && !defined(__ICL)
        // && !defined(__ICC) && !defined(__ECC) && !defined(__PATHSCALE__)
+ // && (!defined(__arm__) || (defined(__arm__) &&
+ // (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) || (__GNUC__ > 4)))
 
 #endif // BOOST_ASIO_DETAIL_GCC_FENCED_BLOCK_HPP

Modified: branches/release/boost/asio/detail/impl/descriptor_ops.ipp
==============================================================================
--- branches/release/boost/asio/detail/impl/descriptor_ops.ipp (original)
+++ branches/release/boost/asio/detail/impl/descriptor_ops.ipp 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
@@ -156,7 +156,7 @@
     if (bytes == 0)
     {
       ec = boost::asio::error::eof;
- return 0;
+ return true;
     }
 
     // Retry operation if interrupted by signal.
@@ -169,7 +169,7 @@
       return false;
 
     // Operation is complete.
- if (bytes >= 0)
+ if (bytes > 0)
     {
       ec = boost::system::error_code();
       bytes_transferred = bytes;

Modified: branches/release/boost/asio/detail/impl/dev_poll_reactor.hpp
==============================================================================
--- branches/release/boost/asio/detail/impl/dev_poll_reactor.hpp (original)
+++ branches/release/boost/asio/detail/impl/dev_poll_reactor.hpp 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
@@ -39,25 +39,30 @@
 
 template <typename Time_Traits>
 void dev_poll_reactor::schedule_timer(timer_queue<Time_Traits>& queue,
- const typename Time_Traits::time_type& time, timer_op* op, void* token)
+ const typename Time_Traits::time_type& time,
+ typename timer_queue<Time_Traits>::per_timer_data& timer, timer_op* op)
 {
   boost::asio::detail::mutex::scoped_lock lock(mutex_);
- if (!shutdown_)
+
+ if (shutdown_)
   {
- bool earliest = queue.enqueue_timer(time, op, token);
- io_service_.work_started();
- if (earliest)
- interrupter_.interrupt();
+ io_service_.post_immediate_completion(op);
+ return;
   }
+
+ bool earliest = queue.enqueue_timer(time, timer, op);
+ io_service_.work_started();
+ if (earliest)
+ interrupter_.interrupt();
 }
 
 template <typename Time_Traits>
-std::size_t dev_poll_reactor::cancel_timer(
- timer_queue<Time_Traits>& queue, void* token)
+std::size_t dev_poll_reactor::cancel_timer(timer_queue<Time_Traits>& queue,
+ typename timer_queue<Time_Traits>::per_timer_data& timer)
 {
   boost::asio::detail::mutex::scoped_lock lock(mutex_);
   op_queue<operation> ops;
- std::size_t n = queue.cancel_timer(token, ops);
+ std::size_t n = queue.cancel_timer(timer, ops);
   lock.unlock();
   io_service_.post_deferred_completions(ops);
   return n;

Modified: branches/release/boost/asio/detail/impl/dev_poll_reactor.ipp
==============================================================================
--- branches/release/boost/asio/detail/impl/dev_poll_reactor.ipp (original)
+++ branches/release/boost/asio/detail/impl/dev_poll_reactor.ipp 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
@@ -82,7 +82,10 @@
   boost::asio::detail::mutex::scoped_lock lock(mutex_);
 
   if (shutdown_)
+ {
+ post_immediate_completion(op);
     return;
+ }
 
   if (allow_speculative)
   {

Modified: branches/release/boost/asio/detail/impl/epoll_reactor.hpp
==============================================================================
--- branches/release/boost/asio/detail/impl/epoll_reactor.hpp (original)
+++ branches/release/boost/asio/detail/impl/epoll_reactor.hpp 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
@@ -37,25 +37,30 @@
 
 template <typename Time_Traits>
 void epoll_reactor::schedule_timer(timer_queue<Time_Traits>& queue,
- const typename Time_Traits::time_type& time, timer_op* op, void* token)
+ const typename Time_Traits::time_type& time,
+ typename timer_queue<Time_Traits>::per_timer_data& timer, timer_op* op)
 {
   mutex::scoped_lock lock(mutex_);
- if (!shutdown_)
+
+ if (shutdown_)
   {
- bool earliest = queue.enqueue_timer(time, op, token);
- io_service_.work_started();
- if (earliest)
- update_timeout();
+ io_service_.post_immediate_completion(op);
+ return;
   }
+
+ bool earliest = queue.enqueue_timer(time, timer, op);
+ io_service_.work_started();
+ if (earliest)
+ update_timeout();
 }
 
 template <typename Time_Traits>
-std::size_t epoll_reactor::cancel_timer(
- timer_queue<Time_Traits>& queue, void* token)
+std::size_t epoll_reactor::cancel_timer(timer_queue<Time_Traits>& queue,
+ typename timer_queue<Time_Traits>::per_timer_data& timer)
 {
   mutex::scoped_lock lock(mutex_);
   op_queue<operation> ops;
- std::size_t n = queue.cancel_timer(token, ops);
+ std::size_t n = queue.cancel_timer(timer, ops);
   lock.unlock();
   io_service_.post_deferred_completions(ops);
   return n;

Modified: branches/release/boost/asio/detail/impl/epoll_reactor.ipp
==============================================================================
--- branches/release/boost/asio/detail/impl/epoll_reactor.ipp (original)
+++ branches/release/boost/asio/detail/impl/epoll_reactor.ipp 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
@@ -79,14 +79,12 @@
 
   op_queue<operation> ops;
 
- descriptor_map::iterator iter = registered_descriptors_.begin();
- descriptor_map::iterator end = registered_descriptors_.end();
- while (iter != end)
+ while (descriptor_state* state = registered_descriptors_.first())
   {
     for (int i = 0; i < max_ops; ++i)
- ops.push(iter->second.op_queue_[i]);
- iter->second.shutdown_ = true;
- ++iter;
+ ops.push(state->op_queue_[i]);
+ state->shutdown_ = true;
+ registered_descriptors_.free(state);
   }
 
   timer_queues_.get_all_timers(ops);
@@ -102,10 +100,7 @@
 {
   mutex::scoped_lock lock(registered_descriptors_mutex_);
 
- descriptor_map::iterator new_entry = registered_descriptors_.insert(
- std::make_pair(descriptor, descriptor_state())).first;
- descriptor_data = &new_entry->second;
-
+ descriptor_data = registered_descriptors_.alloc();
   descriptor_data->shutdown_ = false;
 
   lock.unlock();
@@ -124,9 +119,20 @@
     epoll_reactor::per_descriptor_data& descriptor_data,
     reactor_op* op, bool allow_speculative)
 {
+ if (!descriptor_data)
+ {
+ op->ec_ = boost::asio::error::bad_descriptor;
+ post_immediate_completion(op);
+ return;
+ }
+
   mutex::scoped_lock descriptor_lock(descriptor_data->mutex_);
+
   if (descriptor_data->shutdown_)
+ {
+ post_immediate_completion(op);
     return;
+ }
 
   if (descriptor_data->op_queue_[op_type].empty())
   {
@@ -158,6 +164,9 @@
 void epoll_reactor::cancel_ops(socket_type,
     epoll_reactor::per_descriptor_data& descriptor_data)
 {
+ if (!descriptor_data)
+ return;
+
   mutex::scoped_lock descriptor_lock(descriptor_data->mutex_);
 
   op_queue<operation> ops;
@@ -176,34 +185,42 @@
   io_service_.post_deferred_completions(ops);
 }
 
-void epoll_reactor::close_descriptor(socket_type descriptor,
+void epoll_reactor::close_descriptor(socket_type,
     epoll_reactor::per_descriptor_data& descriptor_data)
 {
+ if (!descriptor_data)
+ return;
+
   mutex::scoped_lock descriptor_lock(descriptor_data->mutex_);
   mutex::scoped_lock descriptors_lock(registered_descriptors_mutex_);
 
- // Remove the descriptor from the set of known descriptors. The descriptor
- // will be automatically removed from the epoll set when it is closed.
- descriptor_data->shutdown_ = true;
-
- op_queue<operation> ops;
- for (int i = 0; i < max_ops; ++i)
+ if (!descriptor_data->shutdown_)
   {
- while (reactor_op* op = descriptor_data->op_queue_[i].front())
+ // Remove the descriptor from the set of known descriptors. The descriptor
+ // will be automatically removed from the epoll set when it is closed.
+
+ op_queue<operation> ops;
+ for (int i = 0; i < max_ops; ++i)
     {
- op->ec_ = boost::asio::error::operation_aborted;
- descriptor_data->op_queue_[i].pop();
- ops.push(op);
+ while (reactor_op* op = descriptor_data->op_queue_[i].front())
+ {
+ op->ec_ = boost::asio::error::operation_aborted;
+ descriptor_data->op_queue_[i].pop();
+ ops.push(op);
+ }
     }
- }
 
- descriptor_lock.unlock();
+ descriptor_data->shutdown_ = true;
 
- registered_descriptors_.erase(descriptor);
+ descriptor_lock.unlock();
 
- descriptors_lock.unlock();
+ registered_descriptors_.free(descriptor_data);
+ descriptor_data = 0;
 
- io_service_.post_deferred_completions(ops);
+ descriptors_lock.unlock();
+
+ io_service_.post_deferred_completions(ops);
+ }
 }
 
 void epoll_reactor::run(bool block, op_queue<operation>& ops)

Modified: branches/release/boost/asio/detail/impl/kqueue_reactor.hpp
==============================================================================
--- branches/release/boost/asio/detail/impl/kqueue_reactor.hpp (original)
+++ branches/release/boost/asio/detail/impl/kqueue_reactor.hpp 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
@@ -41,25 +41,30 @@
 
 template <typename Time_Traits>
 void kqueue_reactor::schedule_timer(timer_queue<Time_Traits>& queue,
- const typename Time_Traits::time_type& time, timer_op* op, void* token)
+ const typename Time_Traits::time_type& time,
+ typename timer_queue<Time_Traits>::per_timer_data& timer, timer_op* op)
 {
   boost::asio::detail::mutex::scoped_lock lock(mutex_);
- if (!shutdown_)
+
+ if (shutdown_)
   {
- bool earliest = queue.enqueue_timer(time, op, token);
- io_service_.work_started();
- if (earliest)
- interrupter_.interrupt();
+ io_service_.post_immediate_completion(op);
+ return;
   }
+
+ bool earliest = queue.enqueue_timer(time, timer, op);
+ io_service_.work_started();
+ if (earliest)
+ interrupter_.interrupt();
 }
 
 template <typename Time_Traits>
-std::size_t kqueue_reactor::cancel_timer(
- timer_queue<Time_Traits>& queue, void* token)
+std::size_t kqueue_reactor::cancel_timer(timer_queue<Time_Traits>& queue,
+ typename timer_queue<Time_Traits>::per_timer_data& timer)
 {
   boost::asio::detail::mutex::scoped_lock lock(mutex_);
   op_queue<operation> ops;
- std::size_t n = queue.cancel_timer(token, ops);
+ std::size_t n = queue.cancel_timer(timer, ops);
   lock.unlock();
   io_service_.post_deferred_completions(ops);
   return n;

Modified: branches/release/boost/asio/detail/impl/kqueue_reactor.ipp
==============================================================================
--- branches/release/boost/asio/detail/impl/kqueue_reactor.ipp (original)
+++ branches/release/boost/asio/detail/impl/kqueue_reactor.ipp 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
@@ -57,14 +57,12 @@
 
   op_queue<operation> ops;
 
- descriptor_map::iterator iter = registered_descriptors_.begin();
- descriptor_map::iterator end = registered_descriptors_.end();
- while (iter != end)
+ while (descriptor_state* state = registered_descriptors_.first())
   {
     for (int i = 0; i < max_ops; ++i)
- ops.push(iter->second.op_queue_[i]);
- iter->second.shutdown_ = true;
- ++iter;
+ ops.push(state->op_queue_[i]);
+ state->shutdown_ = true;
+ registered_descriptors_.free(state);
   }
 
   timer_queues_.get_all_timers(ops);
@@ -80,10 +78,7 @@
 {
   mutex::scoped_lock lock(registered_descriptors_mutex_);
 
- descriptor_map::iterator new_entry = registered_descriptors_.insert(
- std::make_pair(descriptor, descriptor_state())).first;
- descriptor_data = &new_entry->second;
-
+ descriptor_data = registered_descriptors_.alloc();
   descriptor_data->shutdown_ = false;
 
   return 0;
@@ -93,9 +88,20 @@
     kqueue_reactor::per_descriptor_data& descriptor_data,
     reactor_op* op, bool allow_speculative)
 {
+ if (!descriptor_data)
+ {
+ op->ec_ = boost::asio::error::bad_descriptor;
+ post_immediate_completion(op);
+ return;
+ }
+
   mutex::scoped_lock descriptor_lock(descriptor_data->mutex_);
+
   if (descriptor_data->shutdown_)
+ {
+ post_immediate_completion(op);
     return;
+ }
 
   bool first = descriptor_data->op_queue_[op_type].empty();
   if (first)
@@ -151,6 +157,9 @@
 void kqueue_reactor::cancel_ops(socket_type,
     kqueue_reactor::per_descriptor_data& descriptor_data)
 {
+ if (!descriptor_data)
+ return;
+
   mutex::scoped_lock descriptor_lock(descriptor_data->mutex_);
 
   op_queue<operation> ops;
@@ -172,31 +181,39 @@
 void kqueue_reactor::close_descriptor(socket_type descriptor,
     kqueue_reactor::per_descriptor_data& descriptor_data)
 {
+ if (!descriptor_data)
+ return;
+
   mutex::scoped_lock descriptor_lock(descriptor_data->mutex_);
   mutex::scoped_lock descriptors_lock(registered_descriptors_mutex_);
 
- // Remove the descriptor from the set of known descriptors. The descriptor
- // will be automatically removed from the kqueue set when it is closed.
- descriptor_data->shutdown_ = true;
-
- op_queue<operation> ops;
- for (int i = 0; i < max_ops; ++i)
+ if (!descriptor_data->shutdown_)
   {
- while (reactor_op* op = descriptor_data->op_queue_[i].front())
+ // Remove the descriptor from the set of known descriptors. The descriptor
+ // will be automatically removed from the kqueue set when it is closed.
+
+ op_queue<operation> ops;
+ for (int i = 0; i < max_ops; ++i)
     {
- op->ec_ = boost::asio::error::operation_aborted;
- descriptor_data->op_queue_[i].pop();
- ops.push(op);
+ while (reactor_op* op = descriptor_data->op_queue_[i].front())
+ {
+ op->ec_ = boost::asio::error::operation_aborted;
+ descriptor_data->op_queue_[i].pop();
+ ops.push(op);
+ }
     }
- }
 
- descriptor_lock.unlock();
+ descriptor_data->shutdown_ = true;
 
- registered_descriptors_.erase(descriptor);
+ descriptor_lock.unlock();
 
- descriptors_lock.unlock();
+ registered_descriptors_.free(descriptor_data);
+ descriptor_data = 0;
 
- io_service_.post_deferred_completions(ops);
+ descriptors_lock.unlock();
+
+ io_service_.post_deferred_completions(ops);
+ }
 }
 
 void kqueue_reactor::run(bool block, op_queue<operation>& ops)

Modified: branches/release/boost/asio/detail/impl/select_reactor.hpp
==============================================================================
--- branches/release/boost/asio/detail/impl/select_reactor.hpp (original)
+++ branches/release/boost/asio/detail/impl/select_reactor.hpp 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
@@ -43,25 +43,30 @@
 
 template <typename Time_Traits>
 void select_reactor::schedule_timer(timer_queue<Time_Traits>& queue,
- const typename Time_Traits::time_type& time, timer_op* op, void* token)
+ const typename Time_Traits::time_type& time,
+ typename timer_queue<Time_Traits>::per_timer_data& timer, timer_op* op)
 {
   boost::asio::detail::mutex::scoped_lock lock(mutex_);
- if (!shutdown_)
+
+ if (shutdown_)
   {
- bool earliest = queue.enqueue_timer(time, op, token);
- io_service_.work_started();
- if (earliest)
- interrupter_.interrupt();
+ io_service_.post_immediate_completion(op);
+ return;
   }
+
+ bool earliest = queue.enqueue_timer(time, timer, op);
+ io_service_.work_started();
+ if (earliest)
+ interrupter_.interrupt();
 }
 
 template <typename Time_Traits>
-std::size_t select_reactor::cancel_timer(
- timer_queue<Time_Traits>& queue, void* token)
+std::size_t select_reactor::cancel_timer(timer_queue<Time_Traits>& queue,
+ typename timer_queue<Time_Traits>::per_timer_data& timer)
 {
   boost::asio::detail::mutex::scoped_lock lock(mutex_);
   op_queue<operation> ops;
- std::size_t n = queue.cancel_timer(token, ops);
+ std::size_t n = queue.cancel_timer(timer, ops);
   lock.unlock();
   io_service_.post_deferred_completions(ops);
   return n;

Modified: branches/release/boost/asio/detail/impl/select_reactor.ipp
==============================================================================
--- branches/release/boost/asio/detail/impl/select_reactor.ipp (original)
+++ branches/release/boost/asio/detail/impl/select_reactor.ipp 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
@@ -99,13 +99,17 @@
     select_reactor::per_descriptor_data&, reactor_op* op, bool)
 {
   boost::asio::detail::mutex::scoped_lock lock(mutex_);
- if (!shutdown_)
+
+ if (shutdown_)
   {
- bool first = op_queue_[op_type].enqueue_operation(descriptor, op);
- io_service_.work_started();
- if (first)
- interrupter_.interrupt();
+ post_immediate_completion(op);
+ return;
   }
+
+ bool first = op_queue_[op_type].enqueue_operation(descriptor, op);
+ io_service_.work_started();
+ if (first)
+ interrupter_.interrupt();
 }
 
 void select_reactor::cancel_ops(socket_type descriptor,

Modified: branches/release/boost/asio/detail/impl/timer_queue.ipp
==============================================================================
--- branches/release/boost/asio/detail/impl/timer_queue.ipp (original)
+++ branches/release/boost/asio/detail/impl/timer_queue.ipp 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
@@ -36,9 +36,9 @@
 }
 
 bool timer_queue<time_traits<boost::posix_time::ptime> >::enqueue_timer(
- const time_type& time, timer_op* op, void* token)
+ const time_type& time, per_timer_data& timer, timer_op* op)
 {
- return impl_.enqueue_timer(time, op, token);
+ return impl_.enqueue_timer(time, timer, op);
 }
 
 bool timer_queue<time_traits<boost::posix_time::ptime> >::empty() const
@@ -71,9 +71,9 @@
 }
 
 std::size_t timer_queue<time_traits<boost::posix_time::ptime> >::cancel_timer(
- void* timer_token, op_queue<operation>& ops)
+ per_timer_data& timer, op_queue<operation>& ops)
 {
- return impl_.cancel_timer(timer_token, ops);
+ return impl_.cancel_timer(timer, ops);
 }
 
 } // namespace detail

Modified: branches/release/boost/asio/detail/impl/win_iocp_io_service.hpp
==============================================================================
--- branches/release/boost/asio/detail/impl/win_iocp_io_service.hpp (original)
+++ branches/release/boost/asio/detail/impl/win_iocp_io_service.hpp 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
@@ -73,23 +73,27 @@
 
 template <typename Time_Traits>
 void win_iocp_io_service::schedule_timer(timer_queue<Time_Traits>& queue,
- const typename Time_Traits::time_type& time, timer_op* op, void* token)
+ const typename Time_Traits::time_type& time,
+ typename timer_queue<Time_Traits>::per_timer_data& timer, timer_op* op)
 {
   // If the service has been shut down we silently discard the timer.
   if (::InterlockedExchangeAdd(&shutdown_, 0) != 0)
+ {
+ post_immediate_completion(op);
     return;
+ }
 
   mutex::scoped_lock lock(dispatch_mutex_);
 
- bool earliest = queue.enqueue_timer(time, op, token);
+ bool earliest = queue.enqueue_timer(time, timer, op);
   work_started();
   if (earliest)
     update_timeout();
 }
 
 template <typename Time_Traits>
-std::size_t win_iocp_io_service::cancel_timer(
- timer_queue<Time_Traits>& queue, void* token)
+std::size_t win_iocp_io_service::cancel_timer(timer_queue<Time_Traits>& queue,
+ typename timer_queue<Time_Traits>::per_timer_data& timer)
 {
   // If the service has been shut down we silently ignore the cancellation.
   if (::InterlockedExchangeAdd(&shutdown_, 0) != 0)
@@ -97,7 +101,7 @@
 
   mutex::scoped_lock lock(dispatch_mutex_);
   op_queue<win_iocp_operation> ops;
- std::size_t n = queue.cancel_timer(token, ops);
+ std::size_t n = queue.cancel_timer(timer, ops);
   post_deferred_completions(ops);
   return n;
 }

Modified: branches/release/boost/asio/detail/impl/win_iocp_socket_service_base.ipp
==============================================================================
--- branches/release/boost/asio/detail/impl/win_iocp_socket_service_base.ipp (original)
+++ branches/release/boost/asio/detail/impl/win_iocp_socket_service_base.ipp 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
@@ -190,6 +190,16 @@
   }
 #endif // defined(BOOST_ASIO_ENABLE_CANCELIO)
 
+ // Cancel any operations started via the reactor.
+ if (!ec)
+ {
+ reactor* r = static_cast<reactor*>(
+ interlocked_compare_exchange_pointer(
+ reinterpret_cast<void**>(&reactor_), 0, 0));
+ if (r)
+ r->cancel_ops(impl.socket_, impl.reactor_data_);
+ }
+
   return ec;
 }
 

Modified: branches/release/boost/asio/detail/kqueue_reactor.hpp
==============================================================================
--- branches/release/boost/asio/detail/kqueue_reactor.hpp (original)
+++ branches/release/boost/asio/detail/kqueue_reactor.hpp 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
@@ -24,9 +24,9 @@
 #include <sys/types.h>
 #include <sys/event.h>
 #include <sys/time.h>
-#include <boost/asio/detail/hash_map.hpp>
 #include <boost/asio/detail/kqueue_reactor_fwd.hpp>
 #include <boost/asio/detail/mutex.hpp>
+#include <boost/asio/detail/object_pool.hpp>
 #include <boost/asio/detail/op_queue.hpp>
 #include <boost/asio/detail/reactor_op.hpp>
 #include <boost/asio/detail/select_interrupter.hpp>
@@ -59,13 +59,13 @@
   // Per-descriptor queues.
   struct descriptor_state
   {
- descriptor_state() {}
- descriptor_state(const descriptor_state&) {}
- void operator=(const descriptor_state&) {}
-
+ friend class kqueue_reactor;
+ friend class object_pool_access;
     mutex mutex_;
     op_queue<reactor_op> op_queue_[max_ops];
     bool shutdown_;
+ descriptor_state* next_;
+ descriptor_state* prev_;
   };
 
   // Per-descriptor data.
@@ -123,12 +123,14 @@
   // specified absolute time.
   template <typename Time_Traits>
   void schedule_timer(timer_queue<Time_Traits>& queue,
- const typename Time_Traits::time_type& time, timer_op* op, void* token);
+ const typename Time_Traits::time_type& time,
+ typename timer_queue<Time_Traits>::per_timer_data& timer, timer_op* op);
 
   // Cancel the timer operations associated with the given token. Returns the
   // number of operations that have been posted or dispatched.
   template <typename Time_Traits>
- std::size_t cancel_timer(timer_queue<Time_Traits>& queue, void* token);
+ std::size_t cancel_timer(timer_queue<Time_Traits>& queue,
+ typename timer_queue<Time_Traits>::per_timer_data& timer);
 
   // Run the kqueue loop.
   BOOST_ASIO_DECL void run(bool block, op_queue<operation>& ops);
@@ -171,15 +173,8 @@
   // Mutex to protect access to the registered descriptors.
   mutex registered_descriptors_mutex_;
 
- // Keep track of all registered descriptors. This code relies on the fact that
- // the hash_map implementation pools deleted nodes, meaning that we can assume
- // our descriptor_state pointer remains valid even after the entry is removed.
- // Technically this is not true for C++98, as that standard says that spliced
- // elements in a list are invalidated. However, C++0x fixes this shortcoming
- // so we'll just assume that C++98 std::list implementations will do the right
- // thing anyway.
- typedef detail::hash_map<socket_type, descriptor_state> descriptor_map;
- descriptor_map registered_descriptors_;
+ // Keep track of all registered descriptors.
+ object_pool<descriptor_state> registered_descriptors_;
 };
 
 } // namespace detail

Modified: branches/release/boost/asio/detail/regex_fwd.hpp
==============================================================================
--- branches/release/boost/asio/detail/regex_fwd.hpp (original)
+++ branches/release/boost/asio/detail/regex_fwd.hpp 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
@@ -21,7 +21,7 @@
 namespace boost {
 
 template <class BidiIterator>
-class sub_match;
+struct sub_match;
 
 template <class BidiIterator, class Allocator>
 class match_results;

Modified: branches/release/boost/asio/detail/select_reactor.hpp
==============================================================================
--- branches/release/boost/asio/detail/select_reactor.hpp (original)
+++ branches/release/boost/asio/detail/select_reactor.hpp 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
@@ -112,12 +112,14 @@
   // specified absolute time.
   template <typename Time_Traits>
   void schedule_timer(timer_queue<Time_Traits>& queue,
- const typename Time_Traits::time_type& time, timer_op* op, void* token);
+ const typename Time_Traits::time_type& time,
+ typename timer_queue<Time_Traits>::per_timer_data& timer, timer_op* op);
 
   // Cancel the timer operations associated with the given token. Returns the
   // number of operations that have been posted or dispatched.
   template <typename Time_Traits>
- std::size_t cancel_timer(timer_queue<Time_Traits>& queue, void* token);
+ std::size_t cancel_timer(timer_queue<Time_Traits>& queue,
+ typename timer_queue<Time_Traits>::per_timer_data& timer);
 
   // Run select once until interrupted or events are ready to be dispatched.
   BOOST_ASIO_DECL void run(bool block, op_queue<operation>& ops);

Modified: branches/release/boost/asio/detail/timer_queue.hpp
==============================================================================
--- branches/release/boost/asio/detail/timer_queue.hpp (original)
+++ branches/release/boost/asio/detail/timer_queue.hpp 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
@@ -17,11 +17,9 @@
 
 #include <boost/asio/detail/config.hpp>
 #include <cstddef>
-#include <memory>
 #include <vector>
 #include <boost/config.hpp>
 #include <boost/limits.hpp>
-#include <boost/asio/detail/hash_map.hpp>
 #include <boost/asio/detail/op_queue.hpp>
 #include <boost/asio/detail/timer_op.hpp>
 #include <boost/asio/detail/timer_queue_base.hpp>
@@ -49,6 +47,26 @@
   // The duration type.
   typedef typename Time_Traits::duration_type duration_type;
 
+ // Per-timer data.
+ class per_timer_data
+ {
+ public:
+ per_timer_data() : next_(0), prev_(0) {}
+
+ private:
+ friend class timer_queue;
+
+ // The operations waiting on the timer.
+ op_queue<timer_op> op_queue_;
+
+ // The index of the timer in the heap.
+ std::size_t heap_index_;
+
+ // Pointers to adjacent timers in a linked list.
+ per_timer_data* next_;
+ per_timer_data* prev_;
+ };
+
   // Constructor.
   timer_queue()
     : timers_(),
@@ -59,35 +77,44 @@
   // Add a new timer to the queue. Returns true if this is the timer that is
   // earliest in the queue, in which case the reactor's event demultiplexing
   // function call may need to be interrupted and restarted.
- bool enqueue_timer(const time_type& time, timer_op* op, void* token)
+ bool enqueue_timer(const time_type& time, per_timer_data& timer, timer_op* op)
   {
     // Ensure that there is space for the timer in the heap. We reserve here so
     // that the push_back below will not throw due to a reallocation failure.
     heap_.reserve(heap_.size() + 1);
 
- // Insert the new timer into the hash.
- typedef typename hash_map<void*, timer>::iterator iterator;
- typedef typename hash_map<void*, timer>::value_type value_type;
- std::pair<iterator, bool> result =
- timers_.insert(value_type(token, timer()));
- result.first->second.op_queue_.push(op);
- if (result.second)
+ timer.op_queue_.push(op);
+ if (timer.prev_ == 0 && &timer != timers_)
     {
+ // Insert the new timer into the linked list of active timers.
+ timer.next_ = timers_;
+ timer.prev_ = 0;
+ if (timers_)
+ timers_->prev_ = &timer;
+ timers_ = &timer;
+
       // Put the new timer at the correct position in the heap.
- result.first->second.time_ = time;
- result.first->second.heap_index_ = heap_.size();
- result.first->second.token_ = token;
- heap_.push_back(&result.first->second);
- up_heap(heap_.size() - 1);
+ if (this->is_positive_infinity(time))
+ {
+ timer.heap_index_ = (std::numeric_limits<std::size_t>::max)();
+ return false; // No need to interrupt reactor as timer never expires.
+ }
+ else
+ {
+ timer.heap_index_ = heap_.size();
+ heap_entry entry = { time, &timer };
+ heap_.push_back(entry);
+ up_heap(heap_.size() - 1);
+ }
     }
 
- return (heap_[0] == &result.first->second);
+ return (heap_[0].timer_ == &timer);
   }
 
   // Whether there are no timers in the queue.
   virtual bool empty() const
   {
- return heap_.empty();
+ return timers_ == 0;
   }
 
   // Get the time for the timer that is earliest in the queue.
@@ -97,7 +124,7 @@
       return max_duration;
 
     boost::posix_time::time_duration duration = Time_Traits::to_posix_duration(
- Time_Traits::subtract(heap_[0]->time_, Time_Traits::now()));
+ Time_Traits::subtract(heap_[0].time_, Time_Traits::now()));
 
     if (duration > boost::posix_time::milliseconds(max_duration))
       duration = boost::posix_time::milliseconds(max_duration);
@@ -116,7 +143,7 @@
       return max_duration;
 
     boost::posix_time::time_duration duration = Time_Traits::to_posix_duration(
- Time_Traits::subtract(heap_[0]->time_, Time_Traits::now()));
+ Time_Traits::subtract(heap_[0].time_, Time_Traits::now()));
 
     if (duration > boost::posix_time::microseconds(max_duration))
       duration = boost::posix_time::microseconds(max_duration);
@@ -132,77 +159,54 @@
   virtual void get_ready_timers(op_queue<operation>& ops)
   {
     const time_type now = Time_Traits::now();
- while (!heap_.empty() && !Time_Traits::less_than(now, heap_[0]->time_))
+ while (!heap_.empty() && !Time_Traits::less_than(now, heap_[0].time_))
     {
- timer* t = heap_[0];
- ops.push(t->op_queue_);
- remove_timer(t);
+ per_timer_data* timer = heap_[0].timer_;
+ ops.push(timer->op_queue_);
+ remove_timer(*timer);
     }
   }
 
   // Dequeue all timers.
   virtual void get_all_timers(op_queue<operation>& ops)
   {
- typename hash_map<void*, timer>::iterator i = timers_.begin();
- typename hash_map<void*, timer>::iterator end = timers_.end();
- while (i != end)
+ while (timers_)
     {
- ops.push(i->second.op_queue_);
- typename hash_map<void*, timer>::iterator old_i = i++;
- timers_.erase(old_i);
+ per_timer_data* timer = timers_;
+ timers_ = timers_->next_;
+ ops.push(timer->op_queue_);
+ timer->next_ = 0;
+ timer->prev_ = 0;
     }
 
     heap_.clear();
- timers_.clear();
   }
 
   // Cancel and dequeue the timers with the given token.
- std::size_t cancel_timer(void* timer_token, op_queue<operation>& ops)
+ std::size_t cancel_timer(per_timer_data& timer, op_queue<operation>& ops)
   {
     std::size_t num_cancelled = 0;
- typedef typename hash_map<void*, timer>::iterator iterator;
- iterator it = timers_.find(timer_token);
- if (it != timers_.end())
+ if (timer.prev_ != 0 || &timer == timers_)
     {
- while (timer_op* op = it->second.op_queue_.front())
+ while (timer_op* op = timer.op_queue_.front())
       {
         op->ec_ = boost::asio::error::operation_aborted;
- it->second.op_queue_.pop();
+ timer.op_queue_.pop();
         ops.push(op);
         ++num_cancelled;
       }
- remove_timer(&it->second);
+ remove_timer(timer);
     }
     return num_cancelled;
   }
 
 private:
- // Structure representing a single outstanding timer.
- struct timer
- {
- timer() {}
- timer(const timer&) {}
- void operator=(const timer&) {}
-
- // The time when the timer should fire.
- time_type time_;
-
- // The operations waiting on the timer.
- op_queue<timer_op> op_queue_;
-
- // The index of the timer in the heap.
- size_t heap_index_;
-
- // The token associated with the timer.
- void* token_;
- };
-
   // Move the item at the given index up the heap to its correct position.
- void up_heap(size_t index)
+ void up_heap(std::size_t index)
   {
- size_t parent = (index - 1) / 2;
+ std::size_t parent = (index - 1) / 2;
     while (index > 0
- && Time_Traits::less_than(heap_[index]->time_, heap_[parent]->time_))
+ && Time_Traits::less_than(heap_[index].time_, heap_[parent].time_))
     {
       swap_heap(index, parent);
       index = parent;
@@ -211,16 +215,16 @@
   }
 
   // Move the item at the given index down the heap to its correct position.
- void down_heap(size_t index)
+ void down_heap(std::size_t index)
   {
- size_t child = index * 2 + 1;
+ std::size_t child = index * 2 + 1;
     while (child < heap_.size())
     {
- size_t min_child = (child + 1 == heap_.size()
+ std::size_t min_child = (child + 1 == heap_.size()
           || Time_Traits::less_than(
- heap_[child]->time_, heap_[child + 1]->time_))
+ heap_[child].time_, heap_[child + 1].time_))
         ? child : child + 1;
- if (Time_Traits::less_than(heap_[index]->time_, heap_[min_child]->time_))
+ if (Time_Traits::less_than(heap_[index].time_, heap_[min_child].time_))
         break;
       swap_heap(index, min_child);
       index = min_child;
@@ -229,20 +233,20 @@
   }
 
   // Swap two entries in the heap.
- void swap_heap(size_t index1, size_t index2)
+ void swap_heap(std::size_t index1, std::size_t index2)
   {
- timer* tmp = heap_[index1];
+ heap_entry tmp = heap_[index1];
     heap_[index1] = heap_[index2];
     heap_[index2] = tmp;
- heap_[index1]->heap_index_ = index1;
- heap_[index2]->heap_index_ = index2;
+ heap_[index1].timer_->heap_index_ = index1;
+ heap_[index2].timer_->heap_index_ = index2;
   }
 
   // Remove a timer from the heap and list of timers.
- void remove_timer(timer* t)
+ void remove_timer(per_timer_data& timer)
   {
     // Remove the timer from the heap.
- size_t index = t->heap_index_;
+ std::size_t index = timer.heap_index_;
     if (!heap_.empty() && index < heap_.size())
     {
       if (index == heap_.size() - 1)
@@ -253,27 +257,53 @@
       {
         swap_heap(index, heap_.size() - 1);
         heap_.pop_back();
- size_t parent = (index - 1) / 2;
+ std::size_t parent = (index - 1) / 2;
         if (index > 0 && Time_Traits::less_than(
- heap_[index]->time_, heap_[parent]->time_))
+ heap_[index].time_, heap_[parent].time_))
           up_heap(index);
         else
           down_heap(index);
       }
     }
 
- // Remove the timer from the hash.
- typedef typename hash_map<void*, timer>::iterator iterator;
- iterator it = timers_.find(t->token_);
- if (it != timers_.end())
- timers_.erase(it);
+ // Remove the timer from the linked list of active timers.
+ if (timers_ == &timer)
+ timers_ = timer.next_;
+ if (timer.prev_)
+ timer.prev_->next_ = timer.next_;
+ if (timer.next_)
+ timer.next_->prev_= timer.prev_;
+ timer.next_ = 0;
+ timer.prev_ = 0;
+ }
+
+ // Determine if the specified absolute time is positive infinity.
+ template <typename Time_Type>
+ static bool is_positive_infinity(const Time_Type&)
+ {
+ return false;
+ }
+
+ // Determine if the specified absolute time is positive infinity.
+ static bool is_positive_infinity(const boost::posix_time::ptime& time)
+ {
+ return time == boost::posix_time::pos_infin;
   }
 
- // A hash of timer token to linked lists of timers.
- hash_map<void*, timer> timers_;
+ // The head of a linked list of all active timers.
+ per_timer_data* timers_;
+
+ struct heap_entry
+ {
+ // The time when the timer should fire.
+ time_type time_;
+
+ // The associated timer with enqueued operations.
+ per_timer_data* timer_;
+ };
 
   // The heap of timers, with the earliest timer at the front.
- std::vector<timer*> heap_;
+ std::vector<heap_entry> heap_;
 };
 
 #if !defined(BOOST_ASIO_HEADER_ONLY)
@@ -292,6 +322,10 @@
   // The duration type.
   typedef boost::posix_time::time_duration duration_type;
 
+ // Per-timer data.
+ typedef timer_queue<forwarding_posix_time_traits>::per_timer_data
+ per_timer_data;
+
   // Constructor.
   BOOST_ASIO_DECL timer_queue();
 
@@ -302,7 +336,7 @@
   // earliest in the queue, in which case the reactor's event demultiplexing
   // function call may need to be interrupted and restarted.
   BOOST_ASIO_DECL bool enqueue_timer(const time_type& time,
- timer_op* op, void* token);
+ per_timer_data& timer, timer_op* op);
 
   // Whether there are no timers in the queue.
   BOOST_ASIO_DECL virtual bool empty() const;
@@ -321,7 +355,7 @@
 
   // Cancel and dequeue the timers with the given token.
   BOOST_ASIO_DECL std::size_t cancel_timer(
- void* timer_token, op_queue<operation>& ops);
+ per_timer_data& timer, op_queue<operation>& ops);
 
 private:
   timer_queue<forwarding_posix_time_traits> impl_;

Modified: branches/release/boost/asio/detail/win_fenced_block.hpp
==============================================================================
--- branches/release/boost/asio/detail/win_fenced_block.hpp (original)
+++ branches/release/boost/asio/detail/win_fenced_block.hpp 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
@@ -34,7 +34,10 @@
   // Constructor.
   win_fenced_block()
   {
-#if defined(BOOST_MSVC) && (BOOST_MSVC < 1400)
+#if defined(__BORLANDC__)
+ LONG barrier = 0;
+ ::InterlockedExchange(&barrier, 1);
+#elif defined(BOOST_MSVC) && ((BOOST_MSVC < 1400) || !defined(MemoryBarrier))
 # if defined(_M_IX86)
 # pragma warning(push)
 # pragma warning(disable:4793)
@@ -42,15 +45,18 @@
     __asm { xchg barrier, eax }
 # pragma warning(pop)
 # endif // defined(_M_IX86)
-#else // defined(BOOST_MSVC) && (BOOST_MSVC < 1400)
+#else
     MemoryBarrier();
-#endif // defined(BOOST_MSVC) && (BOOST_MSVC < 1400)
+#endif
   }
 
   // Destructor.
   ~win_fenced_block()
   {
-#if defined(BOOST_MSVC) && (BOOST_MSVC < 1400)
+#if defined(__BORLANDC__)
+ LONG barrier = 0;
+ ::InterlockedExchange(&barrier, 1);
+#elif defined(BOOST_MSVC) && ((BOOST_MSVC < 1400) || !defined(MemoryBarrier))
 # if defined(_M_IX86)
 # pragma warning(push)
 # pragma warning(disable:4793)
@@ -58,18 +64,10 @@
     __asm { xchg barrier, eax }
 # pragma warning(pop)
 # endif // defined(_M_IX86)
-#else // defined(BOOST_MSVC) && (BOOST_MSVC < 1400)
+#else
     MemoryBarrier();
-#endif // defined(BOOST_MSVC) && (BOOST_MSVC < 1400)
- }
-
-#if defined(__BORLANDC__)
- static void MemoryBarrier()
- {
- LONG barrier = 0;
- ::InterlockedExchange(&barrier, 1);
+#endif
   }
-#endif // defined(__BORLANDC__)
 };
 
 } // namespace detail

Modified: branches/release/boost/asio/detail/win_iocp_io_service.hpp
==============================================================================
--- branches/release/boost/asio/detail/win_iocp_io_service.hpp (original)
+++ branches/release/boost/asio/detail/win_iocp_io_service.hpp 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
@@ -148,13 +148,15 @@
   // Schedule a new operation in the given timer queue to expire at the
   // specified absolute time.
   template <typename Time_Traits>
- void schedule_timer(timer_queue<Time_Traits>& timer_queue,
- const typename Time_Traits::time_type& time, timer_op* op, void* token);
+ void schedule_timer(timer_queue<Time_Traits>& queue,
+ const typename Time_Traits::time_type& time,
+ typename timer_queue<Time_Traits>::per_timer_data& timer, timer_op* op);
 
   // Cancel the timer associated with the given token. Returns the number of
   // handlers that have been posted or dispatched.
   template <typename Time_Traits>
- std::size_t cancel_timer(timer_queue<Time_Traits>& timer_queue, void* token);
+ std::size_t cancel_timer(timer_queue<Time_Traits>& queue,
+ typename timer_queue<Time_Traits>::per_timer_data& timer);
 
 private:
 #if defined(WINVER) && (WINVER < 0x0500)

Modified: branches/release/boost/asio/impl/read.hpp
==============================================================================
--- branches/release/boost/asio/impl/read.hpp (original)
+++ branches/release/boost/asio/impl/read.hpp 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
@@ -160,7 +160,7 @@
             break;
         }
 
- handler_(ec, total_transferred_);
+ handler_(ec, static_cast<const std::size_t>(total_transferred_));
       }
     }
 
@@ -212,7 +212,7 @@
             break;
         }
 
- handler_(ec, total_transferred_);
+ handler_(ec, static_cast<const std::size_t>(total_transferred_));
       }
     }
 
@@ -317,7 +317,7 @@
             break;
         }
 
- handler_(ec, total_transferred_);
+ handler_(ec, static_cast<const std::size_t>(total_transferred_));
       }
     }
 

Modified: branches/release/boost/asio/impl/read_at.hpp
==============================================================================
--- branches/release/boost/asio/impl/read_at.hpp (original)
+++ branches/release/boost/asio/impl/read_at.hpp 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
@@ -173,7 +173,7 @@
             break;
         }
 
- handler_(ec, total_transferred_);
+ handler_(ec, static_cast<const std::size_t>(total_transferred_));
       }
     }
 
@@ -226,7 +226,7 @@
             break;
         }
 
- handler_(ec, total_transferred_);
+ handler_(ec, static_cast<const std::size_t>(total_transferred_));
       }
     }
 
@@ -338,7 +338,7 @@
             break;
         }
 
- handler_(ec, total_transferred_);
+ handler_(ec, static_cast<const std::size_t>(total_transferred_));
       }
     }
 

Modified: branches/release/boost/asio/impl/write.hpp
==============================================================================
--- branches/release/boost/asio/impl/write.hpp (original)
+++ branches/release/boost/asio/impl/write.hpp 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
@@ -146,7 +146,7 @@
             break;
         }
 
- handler_(ec, total_transferred_);
+ handler_(ec, static_cast<const std::size_t>(total_transferred_));
       }
     }
 
@@ -198,7 +198,7 @@
             break;
         }
 
- handler_(ec, total_transferred_);
+ handler_(ec, static_cast<const std::size_t>(total_transferred_));
       }
     }
 
@@ -249,7 +249,7 @@
             break;
         }
 
- handler_(ec, total_transferred_);
+ handler_(ec, static_cast<const std::size_t>(total_transferred_));
       }
     }
 
@@ -328,7 +328,7 @@
     }
 
     void operator()(const boost::system::error_code& ec,
- std::size_t bytes_transferred)
+ const std::size_t bytes_transferred)
     {
       streambuf_.consume(bytes_transferred);
       handler_(ec, bytes_transferred);

Modified: branches/release/boost/asio/impl/write_at.hpp
==============================================================================
--- branches/release/boost/asio/impl/write_at.hpp (original)
+++ branches/release/boost/asio/impl/write_at.hpp 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
@@ -157,7 +157,7 @@
             break;
         }
 
- handler_(ec, total_transferred_);
+ handler_(ec, static_cast<const std::size_t>(total_transferred_));
       }
     }
 
@@ -211,7 +211,7 @@
             break;
         }
 
- handler_(ec, total_transferred_);
+ handler_(ec, static_cast<const std::size_t>(total_transferred_));
       }
     }
 
@@ -264,7 +264,7 @@
             break;
         }
 
- handler_(ec, total_transferred_);
+ handler_(ec, static_cast<const std::size_t>(total_transferred_));
       }
     }
 
@@ -347,7 +347,7 @@
     }
 
     void operator()(const boost::system::error_code& ec,
- std::size_t bytes_transferred)
+ const std::size_t bytes_transferred)
     {
       streambuf_.consume(bytes_transferred);
       handler_(ec, bytes_transferred);

Modified: branches/release/libs/asio/doc/examples.qbk
==============================================================================
--- branches/release/libs/asio/doc/examples.qbk (original)
+++ branches/release/libs/asio/doc/examples.qbk 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
@@ -243,10 +243,10 @@
 A collection of examples showing how to cancel long running asynchronous
 operations after a period of time.
 
-* [@boost_asio/example/timeouts/accept_timeout.cpp]
-* [@boost_asio/example/timeouts/connect_timeout.cpp]
-* [@boost_asio/example/timeouts/datagram_receive_timeout.cpp]
-* [@boost_asio/example/timeouts/stream_receive_timeout.cpp]
+* [@boost_asio/example/timeouts/async_tcp_client.cpp]
+* [@boost_asio/example/timeouts/blocking_tcp_client.cpp]
+* [@boost_asio/example/timeouts/blocking_udp_client.cpp]
+* [@boost_asio/example/timeouts/server.cpp]
 
 
 [heading Timers]

Modified: branches/release/libs/asio/doc/reference.qbk
==============================================================================
--- branches/release/libs/asio/doc/reference.qbk (original)
+++ branches/release/libs/asio/doc/reference.qbk 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
@@ -34151,13 +34151,29 @@
 [endsect]
 
 
-
 [section:operator_plus_ buffers_iterator::operator+]
 
 [indexterm2 operator+..buffers_iterator]
 Addition operator.
 
 
+ friend buffers_iterator ``[link boost_asio.reference.buffers_iterator.operator_plus_.overload1 operator+]``(
+ const buffers_iterator & iter,
+ std::ptrdiff_t difference);
+ `` [''''&raquo;''' [link boost_asio.reference.buffers_iterator.operator_plus_.overload1 more...]]``
+
+ friend buffers_iterator ``[link boost_asio.reference.buffers_iterator.operator_plus_.overload2 operator+]``(
+ std::ptrdiff_t difference,
+ const buffers_iterator & iter);
+ `` [''''&raquo;''' [link boost_asio.reference.buffers_iterator.operator_plus_.overload2 more...]]``
+
+
+[section:overload1 buffers_iterator::operator+ (1 of 2 overloads)]
+
+
+Addition operator.
+
+
   friend buffers_iterator operator+(
       const buffers_iterator & iter,
       std::ptrdiff_t difference);
@@ -34173,6 +34189,30 @@
 [endsect]
 
 
+
+[section:overload2 buffers_iterator::operator+ (2 of 2 overloads)]
+
+
+Addition operator.
+
+
+ friend buffers_iterator operator+(
+ std::ptrdiff_t difference,
+ const buffers_iterator & iter);
+
+
+[heading Requirements]
+
+[*Header: ][^boost/asio/buffers_iterator.hpp]
+
+[*Convenience header: ][^boost/asio.hpp]
+
+
+[endsect]
+
+
+[endsect]
+
 [section:operator_plus__plus_ buffers_iterator::operator++]
 
 [indexterm2 operator++..buffers_iterator]

Modified: branches/release/libs/asio/example/http/server4/coroutine.hpp
==============================================================================
--- branches/release/libs/asio/example/http/server4/coroutine.hpp (original)
+++ branches/release/libs/asio/example/http/server4/coroutine.hpp 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
@@ -50,11 +50,11 @@
     } \
     else case 0:
 
-#define CORO_YIELD \
- for (_coro_value = __LINE__;;) \
+#define CORO_YIELD_IMPL(n) \
+ for (_coro_value = (n);;) \
     if (_coro_value == 0) \
     { \
- case __LINE__: ; \
+ case (n): ; \
       break; \
     } \
     else \
@@ -67,13 +67,21 @@
               goto bail_out_of_coroutine; \
             else case 0:
 
-#define CORO_FORK \
- for (_coro_value = -__LINE__;; _coro_value = __LINE__) \
- if (_coro_value == __LINE__) \
+#define CORO_FORK_IMPL(n) \
+ for (_coro_value = -(n);; _coro_value = (n)) \
+ if (_coro_value == (n)) \
     { \
- case -__LINE__: ; \
+ case -(n): ; \
       break; \
     } \
     else
 
+#if defined(_MSC_VER)
+# define CORO_YIELD CORO_YIELD_IMPL(__COUNTER__ + 1)
+# define CORO_FORK CORO_FORK_IMPL(__COUNTER__ + 1)
+#else // defined(_MSC_VER)
+# define CORO_YIELD CORO_YIELD_IMPL(__LINE__)
+# define CORO_FORK CORO_FORK_IMPL(__LINE__)
+#endif // defined(_MSC_VER)
+
 #endif // COROUTINE_HPP

Modified: branches/release/libs/asio/example/timeouts/Jamfile
==============================================================================
--- branches/release/libs/asio/example/timeouts/Jamfile (original)
+++ branches/release/libs/asio/example/timeouts/Jamfile 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
@@ -32,22 +32,22 @@
     $(SOCKET_LIBS)
   ;
 
-exe accept_timeout
+exe async_tcp_client
   : <template>asio_timeouts_example
- accept_timeout.cpp
+ async_tcp_client.cpp
   ;
 
-exe connect_timeout
+exe blocking_tcp_client
   : <template>asio_timeouts_example
- connect_timeout.cpp
+ blocking_tcp_client.cpp
   ;
 
-exe datagram_receive_timeout
+exe blocking_udp_client
   : <template>asio_timeouts_example
- datagram_receive_timeout.cpp
+ blocking_udp_client.cpp
   ;
 
-exe stream_receive_timeout
+exe server
   : <template>asio_timeouts_example
- stream_receive_timeout.cpp
+ server.cpp
   ;

Modified: branches/release/libs/asio/example/timeouts/Jamfile.v2
==============================================================================
--- branches/release/libs/asio/example/timeouts/Jamfile.v2 (original)
+++ branches/release/libs/asio/example/timeouts/Jamfile.v2 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
@@ -37,7 +37,7 @@
     <os>HPUX:<library>ipv6
   ;
 
-exe accept_timeout : accept_timeout.cpp ;
-exe connect_timeout : connect_timeout.cpp ;
-exe datagram_receive_timeout : datagram_receive_timeout.cpp ;
-exe stream_receive_timeout : stream_receive_timeout.cpp ;
+exe async_tcp_client : async_tcp_client.cpp ;
+exe blocking_tcp_client : blocking_tcp_client.cpp ;
+exe blocking_udp_client : blocking_udp_client.cpp ;
+exe server : server.cpp ;

Deleted: branches/release/libs/asio/example/timeouts/accept_timeout.cpp
==============================================================================
--- branches/release/libs/asio/example/timeouts/accept_timeout.cpp 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
+++ (empty file)
@@ -1,74 +0,0 @@
-//
-// accept_timeout.cpp
-// ~~~~~~~~~~~~~~~~~~
-//
-// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
-//
-// 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)
-//
-
-#include <boost/asio.hpp>
-#include <boost/bind.hpp>
-#include <boost/date_time/posix_time/posix_time_types.hpp>
-#include <iostream>
-
-using namespace boost::asio;
-using boost::asio::ip::tcp;
-
-class accept_handler
-{
-public:
- accept_handler(io_service& ios)
- : io_service_(ios),
- timer_(ios),
- acceptor_(ios, tcp::endpoint(tcp::v4(), 32123)),
- socket_(ios)
- {
- acceptor_.async_accept(socket_,
- boost::bind(&accept_handler::handle_accept, this,
- boost::asio::placeholders::error));
-
- timer_.expires_from_now(boost::posix_time::seconds(5));
- timer_.async_wait(boost::bind(&accept_handler::close, this));
- }
-
- void handle_accept(const boost::system::error_code& err)
- {
- if (err)
- {
- std::cout << "Accept error: " << err.message() << "\n";
- }
- else
- {
- std::cout << "Successful accept\n";
- }
- }
-
- void close()
- {
- acceptor_.close();
- }
-
-private:
- io_service& io_service_;
- deadline_timer timer_;
- tcp::acceptor acceptor_;
- tcp::socket socket_;
-};
-
-int main()
-{
- try
- {
- io_service ios;
- accept_handler ah(ios);
- ios.run();
- }
- catch (std::exception& e)
- {
- std::cerr << "Exception: " << e.what() << "\n";
- }
-
- return 0;
-}

Deleted: branches/release/libs/asio/example/timeouts/connect_timeout.cpp
==============================================================================
--- branches/release/libs/asio/example/timeouts/connect_timeout.cpp 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
+++ (empty file)
@@ -1,85 +0,0 @@
-//
-// connect_timeout.cpp
-// ~~~~~~~~~~~~~~~~~~~
-//
-// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
-//
-// 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)
-//
-
-#include <boost/asio.hpp>
-#include <boost/bind.hpp>
-#include <boost/date_time/posix_time/posix_time_types.hpp>
-#include <iostream>
-
-using namespace boost::asio;
-using boost::asio::ip::tcp;
-
-class connect_handler
-{
-public:
- connect_handler(io_service& ios)
- : io_service_(ios),
- timer_(ios),
- socket_(ios)
- {
- socket_.async_connect(
- tcp::endpoint(boost::asio::ip::address_v4::loopback(), 32123),
- boost::bind(&connect_handler::handle_connect, this,
- boost::asio::placeholders::error));
-
- timer_.expires_from_now(boost::posix_time::seconds(5));
- timer_.async_wait(boost::bind(&connect_handler::close, this));
- }
-
- void handle_connect(const boost::system::error_code& err)
- {
- if (err)
- {
- std::cout << "Connect error: " << err.message() << "\n";
- }
- else
- {
- std::cout << "Successful connection\n";
- }
- }
-
- void close()
- {
- socket_.close();
- }
-
-private:
- io_service& io_service_;
- deadline_timer timer_;
- tcp::socket socket_;
-};
-
-int main()
-{
- try
- {
- io_service ios;
- tcp::acceptor a(ios, tcp::endpoint(tcp::v4(), 32123), 1);
-
- // Make lots of connections so that at least some of them will block.
- connect_handler ch1(ios);
- connect_handler ch2(ios);
- connect_handler ch3(ios);
- connect_handler ch4(ios);
- connect_handler ch5(ios);
- connect_handler ch6(ios);
- connect_handler ch7(ios);
- connect_handler ch8(ios);
- connect_handler ch9(ios);
-
- ios.run();
- }
- catch (std::exception& e)
- {
- std::cerr << "Exception: " << e.what() << "\n";
- }
-
- return 0;
-}

Deleted: branches/release/libs/asio/example/timeouts/datagram_receive_timeout.cpp
==============================================================================
--- branches/release/libs/asio/example/timeouts/datagram_receive_timeout.cpp 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
+++ (empty file)
@@ -1,78 +0,0 @@
-//
-// datagram_receive_timeout.cpp
-// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-//
-// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
-//
-// 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)
-//
-
-#include <boost/asio.hpp>
-#include <boost/bind.hpp>
-#include <boost/date_time/posix_time/posix_time_types.hpp>
-#include <iostream>
-
-using namespace boost::asio;
-using boost::asio::ip::udp;
-
-class datagram_handler
-{
-public:
- datagram_handler(io_service& ios)
- : io_service_(ios),
- timer_(ios),
- socket_(ios, udp::endpoint(udp::v4(), 32124))
- {
- socket_.async_receive_from(
- boost::asio::buffer(data_, max_length), sender_endpoint_,
- boost::bind(&datagram_handler::handle_receive_from, this,
- boost::asio::placeholders::error,
- boost::asio::placeholders::bytes_transferred));
-
- timer_.expires_from_now(boost::posix_time::seconds(5));
- timer_.async_wait(boost::bind(&datagram_handler::close, this));
- }
-
- void handle_receive_from(const boost::system::error_code& err,
- size_t /*length*/)
- {
- if (err)
- {
- std::cout << "Receive error: " << err.message() << "\n";
- }
- else
- {
- std::cout << "Successful receive\n";
- }
- }
-
- void close()
- {
- socket_.close();
- }
-
-private:
- io_service& io_service_;
- deadline_timer timer_;
- udp::socket socket_;
- udp::endpoint sender_endpoint_;
- enum { max_length = 512 };
- char data_[max_length];
-};
-
-int main()
-{
- try
- {
- io_service ios;
- datagram_handler dh(ios);
- ios.run();
- }
- catch (std::exception& e)
- {
- std::cerr << "Exception: " << e.what() << "\n";
- }
-
- return 0;
-}

Deleted: branches/release/libs/asio/example/timeouts/stream_receive_timeout.cpp
==============================================================================
--- branches/release/libs/asio/example/timeouts/stream_receive_timeout.cpp 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
+++ (empty file)
@@ -1,102 +0,0 @@
-//
-// stream_receive_timeout.cpp
-// ~~~~~~~~~~~~~~~~~~~~~~~~~~
-//
-// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
-//
-// 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)
-//
-
-#include <boost/asio.hpp>
-#include <boost/bind.hpp>
-#include <boost/date_time/posix_time/posix_time_types.hpp>
-#include <iostream>
-
-using namespace boost::asio;
-using boost::asio::ip::tcp;
-
-class stream_handler
-{
-public:
- stream_handler(io_service& ios)
- : io_service_(ios),
- timer_(ios),
- acceptor_(ios, tcp::endpoint(tcp::v4(), 32123)),
- socket_(ios)
- {
- acceptor_.async_accept(socket_,
- boost::bind(&stream_handler::handle_accept, this,
- boost::asio::placeholders::error));
- }
-
- void handle_accept(const boost::system::error_code& err)
- {
- if (err)
- {
- std::cout << "Accept error: " << err.message() << "\n";
- }
- else
- {
- std::cout << "Successful accept\n";
-
- socket_.async_read_some(boost::asio::buffer(buf_, sizeof(buf_)),
- boost::bind(&stream_handler::handle_recv, this,
- boost::asio::placeholders::error));
- timer_.expires_from_now(boost::posix_time::seconds(5));
- timer_.async_wait(boost::bind(&stream_handler::close, this));
- }
- }
-
- void handle_recv(const boost::system::error_code& err)
- {
- if (err)
- {
- std::cout << "Receive error: " << err.message() << "\n";
- }
- else
- {
- std::cout << "Successful receive\n";
- }
- }
-
- void close()
- {
- socket_.close();
- }
-
-private:
- io_service& io_service_;
- deadline_timer timer_;
- tcp::acceptor acceptor_;
- tcp::socket socket_;
- char buf_[1024];
-};
-
-void connect_handler()
-{
- std::cout << "Successful connect\n";
-}
-
-int main()
-{
- try
- {
- io_service ios;
-
- stream_handler sh(ios);
-
- tcp::socket s(ios);
- s.async_connect(
- tcp::endpoint(boost::asio::ip::address_v4::loopback(), 32123),
- boost::bind(connect_handler));
-
- ios.run();
- }
- catch (std::exception& e)
- {
- std::cerr << "Exception: " << e.what() << "\n";
- }
-
- return 0;
-}

Modified: branches/release/libs/asio/test/buffers_iterator.cpp
==============================================================================
--- branches/release/libs/asio/test/buffers_iterator.cpp (original)
+++ branches/release/libs/asio/test/buffers_iterator.cpp 2010-07-06 00:49:47 EDT (Tue, 06 Jul 2010)
@@ -213,6 +213,45 @@
     bi11 += 1;
     bi12 += 1;
 
+ bi1 = bi1 - 1;
+ bi2 = bi2 - 1;
+ bi3 = bi3 - 1;
+ bi4 = bi4 - 1;
+ bi5 = bi5 - 1;
+ bi6 = bi6 - 1;
+ bi7 = bi7 - 1;
+ bi8 = bi8 - 1;
+ bi9 = bi9 - 1;
+ bi10 = bi10 - 1;
+ bi11 = bi11 - 1;
+ bi12 = bi12 - 1;
+
+ bi1 = bi1 + 1;
+ bi2 = bi2 + 1;
+ bi3 = bi3 + 1;
+ bi4 = bi4 + 1;
+ bi5 = bi5 + 1;
+ bi6 = bi6 + 1;
+ bi7 = bi7 + 1;
+ bi8 = bi8 + 1;
+ bi9 = bi9 + 1;
+ bi10 = bi10 + 1;
+ bi11 = bi11 + 1;
+ bi12 = bi12 + 1;
+
+ bi1 = (-1) + bi1;
+ bi2 = (-1) + bi2;
+ bi3 = (-1) + bi3;
+ bi4 = (-1) + bi4;
+ bi5 = (-1) + bi5;
+ bi6 = (-1) + bi6;
+ bi7 = (-1) + bi7;
+ bi8 = (-1) + bi8;
+ bi9 = (-1) + bi9;
+ bi10 = (-1) + bi10;
+ bi11 = (-1) + bi11;
+ bi12 = (-1) + bi12;
+
     (void)static_cast<std::ptrdiff_t>(bi13 - bi1);
     (void)static_cast<std::ptrdiff_t>(bi14 - bi2);
     (void)static_cast<std::ptrdiff_t>(bi15 - bi3);


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk