Update of /cvsroot/boost/boost/boost/asio
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv6071/boost/asio

Modified Files:
        basic_strand.hpp 
Added Files:
        handler_dispatch_hook.hpp 
Log Message:
Change strand implementation so that dispatch will execute a handler
immediately if called from within the strand.

Add hook function for customising handler dispatch.

Need to use reinterpret_cast when testing for enable_connection_aborted
socket option, to allow non-int socket options to compile correctly.


--- NEW FILE: handler_dispatch_hook.hpp ---
//
// handler_dispatch_hook.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2006 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)
//

#ifndef BOOST_ASIO_HANDLER_DISPATCH_HOOK_HPP
#define BOOST_ASIO_HANDLER_DISPATCH_HOOK_HPP

#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)

#include <boost/asio/detail/push_options.hpp>

namespace boost {
namespace asio {

/// Default dispatch function for handlers.
/**
 * Completion handlers for asynchronous operations are invoked by the
 * io_service associated with the corresponding object (e.g. a socket or
 * deadline_timer). Certain guarantees are made on when the handler may be
 * invoked, in particular that a handler can only be invoked from a thread that
 * is currently calling boost::asio::io_service::run() on the corresponding
 * io_service object. Handlers may subsequently be dispatched through other
 * objects (such as boost::asio::strand objects) that provide additional
 * guarantees.
 *
 * When asynchronous operations are composed from other asynchronous
 * operations, all intermediate handlers should be dispatched using the same
 * method as the final handler. This is required to ensure that user-defined
 * objects are not accessed in a way that may violate the guarantees. This
 * hooking function ensures that the dispatch method used for the final handler
 * is accessible at each intermediate step.
 *
 * Implement asio_handler_dispatch for your own handlers to specify a custom
 * dispatching strategy.
 *
 * This default implementation is simply:
 * @code
 * handler();
 * @endcode
 *
 * @par Example:
 * @code
 * class my_handler;
 *
 * template <typename Handler>
 * void asio_handler_dispatch(Handler handler, my_handler* context)
 * {
 *   context->strand_.dispatch(handler);
 * }
 * @endcode
 */
template <typename Handler>
inline void asio_handler_dispatch(Handler handler, ...)
{
  handler();
}

} // namespace asio
} // namespace boost

#include <boost/asio/detail/pop_options.hpp>

#endif // BOOST_ASIO_HANDLER_DISPATCH_HOOK_HPP

Index: basic_strand.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/asio/basic_strand.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- basic_strand.hpp    14 Jun 2006 22:26:30 -0000      1.1
+++ basic_strand.hpp    5 Jul 2006 05:48:09 -0000       1.2
@@ -60,9 +60,11 @@
   /**
    * This function is used to ask the strand to execute the given handler.
    *
-   * The strand object guarantees that only one handler executed through this
-   * strand will be invoked at a time. The handler may be executed inside this
-   * function if the guarantee can be met.
+   * The strand object guarantees that handlers posted or dispatched through
+   * the strand will not be executed concurrently. The handler may be executed
+   * inside this function if the guarantee can be met. If this function is
+   * called from within a handler that was posted or dispatched through the 
same
+   * strand, then the new handler will be executed immediately.
    *
    * The strand's guarantee is in addition to the guarantee provided by the
    * underlying io_service. The io_service guarantees that the handler will 
only
@@ -85,11 +87,11 @@
    * This function is used to ask the strand to execute the given handler, but
    * without allowing the strand to call the handler from inside this function.
    *
-   * The strand object guarantees that only one handler executed through this
-   * strand will be invoked at a time. The strand's guarantee is in addition to
-   * the guarantee provided by the underlying io_service. The io_service
-   * guarantees that the handler will only be called in a thread in which the
-   * io_service's run member function is currently being invoked.
+   * The strand object guarantees that handlers posted or dispatched through
+   * the strand will not be executed concurrently. The strand's guarantee is in
+   * addition to the guarantee provided by the underlying io_service. The
+   * io_service guarantees that the handler will only be called in a thread in
+   * which the io_service's run member function is currently being invoked.
    *
    * @param handler The handler to be called. The strand will make a copy of 
the
    * handler object as required. The function signature of the handler must be:


Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs

Reply via email to