Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r79522 - in trunk/boost/asio/detail: . impl
From: chris_at_[hidden]
Date: 2012-07-15 00:26:09


Author: chris_kohlhoff
Date: 2012-07-15 00:26:05 EDT (Sun, 15 Jul 2012)
New Revision: 79522
URL: http://svn.boost.org/trac/boost/changeset/79522

Log:
Eliminate redundant call to call_stack::contains(this) when dispatching a completion handler.
Text files modified:
   trunk/boost/asio/detail/impl/task_io_service.hpp | 2 +-
   trunk/boost/asio/detail/impl/task_io_service.ipp | 15 +++++++++++++++
   trunk/boost/asio/detail/task_io_service.hpp | 24 +++++++++++++++++-------
   3 files changed, 33 insertions(+), 8 deletions(-)

Modified: trunk/boost/asio/detail/impl/task_io_service.hpp
==============================================================================
--- trunk/boost/asio/detail/impl/task_io_service.hpp (original)
+++ trunk/boost/asio/detail/impl/task_io_service.hpp 2012-07-15 00:26:05 EDT (Sun, 15 Jul 2012)
@@ -45,7 +45,7 @@
 
     BOOST_ASIO_HANDLER_CREATION((p.p, "io_service", this, "dispatch"));
 
- post_immediate_completion(p.p);
+ post_non_private_immediate_completion(p.p);
     p.v = p.p = 0;
   }
 }

Modified: trunk/boost/asio/detail/impl/task_io_service.ipp
==============================================================================
--- trunk/boost/asio/detail/impl/task_io_service.ipp (original)
+++ trunk/boost/asio/detail/impl/task_io_service.ipp 2012-07-15 00:26:05 EDT (Sun, 15 Jul 2012)
@@ -337,6 +337,21 @@
   wake_one_thread_and_unlock(lock);
 }
 
+void task_io_service::post_non_private_immediate_completion(
+ task_io_service::operation* op)
+{
+ work_started();
+ post_non_private_deferred_completion(op);
+}
+
+void task_io_service::post_non_private_deferred_completion(
+ task_io_service::operation* op)
+{
+ mutex::scoped_lock lock(mutex_);
+ op_queue_.push(op);
+ wake_one_thread_and_unlock(lock);
+}
+
 void task_io_service::abandon_operations(
     op_queue<task_io_service::operation>& ops)
 {

Modified: trunk/boost/asio/detail/task_io_service.hpp
==============================================================================
--- trunk/boost/asio/detail/task_io_service.hpp (original)
+++ trunk/boost/asio/detail/task_io_service.hpp 2012-07-15 00:26:05 EDT (Sun, 15 Jul 2012)
@@ -112,14 +112,14 @@
   // that work_started() was previously called for each operation.
   BOOST_ASIO_DECL void post_deferred_completions(op_queue<operation>& ops);
 
- // Request invocation of the given operation using the thread-private queue
- // and return immediately. Assumes that work_started() has not yet been
- // called for the operation.
+ // Request invocation of the given operation, preferring the thread-private
+ // queue if available, and return immediately. Assumes that work_started()
+ // has not yet been called for the operation.
   BOOST_ASIO_DECL void post_private_immediate_completion(operation* op);
 
- // Request invocation of the given operation using the thread-private queue
- // and return immediately. Assumes that work_started() was previously called
- // for the operation.
+ // Request invocation of the given operation, preferring the thread-private
+ // queue if available, and return immediately. Assumes that work_started()
+ // was previously called for the operation.
   BOOST_ASIO_DECL void post_private_deferred_completion(operation* op);
 
   // Process unfinished operations as part of a shutdown_service operation.
@@ -130,7 +130,17 @@
   // Structure containing information about an idle thread.
   struct thread_info;
 
- // Run at most one operation. Blocks only if this_idle_thread is non-null.
+ // Request invocation of the given operation, avoiding the thread-private
+ // queue, and return immediately. Assumes that work_started() has not yet
+ // been called for the operation.
+ BOOST_ASIO_DECL void post_non_private_immediate_completion(operation* op);
+
+ // Request invocation of the given operation, avoiding the thread-private
+ // queue, and return immediately. Assumes that work_started() was previously
+ // called for the operation.
+ BOOST_ASIO_DECL void post_non_private_deferred_completion(operation* op);
+
+ // Run at most one operation. May block.
   BOOST_ASIO_DECL std::size_t do_run_one(mutex::scoped_lock& lock,
       thread_info& this_thread, op_queue<operation>& private_op_queue,
       const boost::system::error_code& ec);


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