summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '3rdParty/Boost/src/boost/asio/strand.hpp')
-rw-r--r--3rdParty/Boost/src/boost/asio/strand.hpp44
1 files changed, 37 insertions, 7 deletions
diff --git a/3rdParty/Boost/src/boost/asio/strand.hpp b/3rdParty/Boost/src/boost/asio/strand.hpp
index 6a1033f..f6b62fb 100644
--- a/3rdParty/Boost/src/boost/asio/strand.hpp
+++ b/3rdParty/Boost/src/boost/asio/strand.hpp
@@ -1,27 +1,28 @@
//
// strand.hpp
// ~~~~~~~~~~
//
-// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2014 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_STRAND_HPP
#define BOOST_ASIO_STRAND_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
+#include <boost/asio/async_result.hpp>
#include <boost/asio/detail/handler_type_requirements.hpp>
#include <boost/asio/detail/strand_service.hpp>
#include <boost/asio/detail/wrapped_handler.hpp>
#include <boost/asio/io_service.hpp>
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
@@ -66,18 +67,21 @@ namespace asio {
* Note that in the following case:
* @code async_op_1(..., s.wrap(a));
* async_op_2(..., s.wrap(b)); @endcode
* the completion of the first async operation will perform @c s.dispatch(a),
* and the second will perform @c s.dispatch(b), but the order in which those
* are performed is unspecified. That is, you cannot state whether one
* happens-before the other. Therefore none of the above conditions are met and
* no ordering guarantee is made.
*
+ * @note The implementation makes no guarantee that handlers posted or
+ * dispatched through different @c strand objects will be invoked concurrently.
+ *
* @par Thread Safety
* @e Distinct @e objects: Safe.@n
* @e Shared @e objects: Safe.
*
* @par Concepts:
* Dispatcher.
*/
class io_service::strand
{
@@ -134,25 +138,32 @@ public:
* 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:
* @code void handler(); @endcode
*/
template <typename CompletionHandler>
- void dispatch(BOOST_ASIO_MOVE_ARG(CompletionHandler) handler)
+ BOOST_ASIO_INITFN_RESULT_TYPE(CompletionHandler, void ())
+ dispatch(BOOST_ASIO_MOVE_ARG(CompletionHandler) handler)
{
// If you get an error on the following line it means that your handler does
// not meet the documented type requirements for a CompletionHandler.
BOOST_ASIO_COMPLETION_HANDLER_CHECK(CompletionHandler, handler) type_check;
- service_.dispatch(impl_, BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler));
+ detail::async_result_init<
+ CompletionHandler, void ()> init(
+ BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler));
+
+ service_.dispatch(impl_, init.handler);
+
+ return init.result.get();
}
/// Request the strand to invoke the given handler and return
/// immediately.
/**
* 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 handlers posted or dispatched through
@@ -160,25 +171,32 @@ public:
* 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:
* @code void handler(); @endcode
*/
template <typename CompletionHandler>
- void post(BOOST_ASIO_MOVE_ARG(CompletionHandler) handler)
+ BOOST_ASIO_INITFN_RESULT_TYPE(CompletionHandler, void ())
+ post(BOOST_ASIO_MOVE_ARG(CompletionHandler) handler)
{
// If you get an error on the following line it means that your handler does
// not meet the documented type requirements for a CompletionHandler.
BOOST_ASIO_COMPLETION_HANDLER_CHECK(CompletionHandler, handler) type_check;
- service_.post(impl_, BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler));
+ detail::async_result_init<
+ CompletionHandler, void ()> init(
+ BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler));
+
+ service_.post(impl_, init.handler);
+
+ return init.result.get();
}
/// Create a new handler that automatically dispatches the wrapped handler
/// on the strand.
/**
* This function is used to create a new handler function object that, when
* invoked, will automatically pass the wrapped handler to the strand's
* dispatch function.
*
@@ -194,23 +212,35 @@ public:
* then the return value is a function object with the signature
* @code void g(A1 a1, ... An an); @endcode
* that, when invoked, executes code equivalent to:
* @code strand.dispatch(boost::bind(f, a1, ... an)); @endcode
*/
template <typename Handler>
#if defined(GENERATING_DOCUMENTATION)
unspecified
#else
- detail::wrapped_handler<strand, Handler>
+ detail::wrapped_handler<strand, Handler, detail::is_continuation_if_running>
#endif
wrap(Handler handler)
{
- return detail::wrapped_handler<io_service::strand, Handler>(*this, handler);
+ return detail::wrapped_handler<io_service::strand, Handler,
+ detail::is_continuation_if_running>(*this, handler);
+ }
+
+ /// Determine whether the strand is running in the current thread.
+ /**
+ * @return @c true if the current thread is executing a handler that was
+ * submitted to the strand using post(), dispatch() or wrap(). Otherwise
+ * returns @c false.
+ */
+ bool running_in_this_thread() const
+ {
+ return service_.running_in_this_thread(impl_);
}
private:
boost::asio::detail::strand_service& service_;
boost::asio::detail::strand_service::implementation_type impl_;
};
/// Typedef for backwards compatibility.
typedef boost::asio::io_service::strand strand;