diff options
author | Remko Tronçon <git@el-tramo.be> | 2012-12-23 13:16:26 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2012-12-23 14:43:26 (GMT) |
commit | 491ddd570a752cf9bda85933bed0c6942e39b1f9 (patch) | |
tree | 10c25c1be8cc08d0497df1dccd56a10fbb30beee /3rdParty/Boost/src/boost/asio/detail/win_iocp_io_service.hpp | |
parent | da7d7a0ca71b80281aa9ff2526290b61ccb0cc60 (diff) | |
download | swift-491ddd570a752cf9bda85933bed0c6942e39b1f9.zip swift-491ddd570a752cf9bda85933bed0c6942e39b1f9.tar.bz2 |
Update Boost to 1.52.0.
Change-Id: I1e56bea2600bf2ed9c5b3aba8c4f9d2a0f350e77
Diffstat (limited to '3rdParty/Boost/src/boost/asio/detail/win_iocp_io_service.hpp')
-rw-r--r-- | 3rdParty/Boost/src/boost/asio/detail/win_iocp_io_service.hpp | 60 |
1 files changed, 48 insertions, 12 deletions
diff --git a/3rdParty/Boost/src/boost/asio/detail/win_iocp_io_service.hpp b/3rdParty/Boost/src/boost/asio/detail/win_iocp_io_service.hpp index 4c88e7b..0e3bb0b 100644 --- a/3rdParty/Boost/src/boost/asio/detail/win_iocp_io_service.hpp +++ b/3rdParty/Boost/src/boost/asio/detail/win_iocp_io_service.hpp @@ -2,7 +2,7 @@ // detail/win_iocp_io_service.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2012 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) @@ -19,18 +19,20 @@ #if defined(BOOST_ASIO_HAS_IOCP) -#include <boost/scoped_ptr.hpp> +#include <boost/limits.hpp> #include <boost/asio/io_service.hpp> +#include <boost/asio/detail/call_stack.hpp> #include <boost/asio/detail/mutex.hpp> #include <boost/asio/detail/op_queue.hpp> +#include <boost/asio/detail/scoped_ptr.hpp> #include <boost/asio/detail/socket_types.hpp> -#include <boost/asio/detail/timer_op.hpp> +#include <boost/asio/detail/thread.hpp> #include <boost/asio/detail/timer_queue_base.hpp> #include <boost/asio/detail/timer_queue_fwd.hpp> #include <boost/asio/detail/timer_queue_set.hpp> +#include <boost/asio/detail/wait_op.hpp> #include <boost/asio/detail/win_iocp_io_service_fwd.hpp> #include <boost/asio/detail/win_iocp_operation.hpp> -#include <boost/asio/detail/thread.hpp> #include <boost/asio/detail/push_options.hpp> @@ -38,16 +40,17 @@ namespace boost { namespace asio { namespace detail { -class timer_op; +class wait_op; class win_iocp_io_service : public boost::asio::detail::service_base<win_iocp_io_service> { public: - // Constructor. - BOOST_ASIO_DECL win_iocp_io_service(boost::asio::io_service& io_service); - BOOST_ASIO_DECL void init(size_t concurrency_hint); + // Constructor. Specifies a concurrency hint that is passed through to the + // underlying I/O completion port. + BOOST_ASIO_DECL win_iocp_io_service(boost::asio::io_service& io_service, + size_t concurrency_hint = 0); // Destroy all user-defined handler objects owned by the service. BOOST_ASIO_DECL void shutdown_service(); @@ -76,6 +79,12 @@ public: // Stop the event processing loop. BOOST_ASIO_DECL void stop(); + // Determine whether the io_service is stopped. + bool stopped() const + { + return ::InterlockedExchangeAdd(&stopped_, 0) != 0; + } + // Reset in preparation for a subsequent run invocation. void reset() { @@ -95,6 +104,12 @@ public: stop(); } + // Return whether a handler can be dispatched immediately. + bool can_dispatch() + { + return call_stack<win_iocp_io_service>::contains(this) != 0; + } + // Request invocation of the given handler. template <typename Handler> void dispatch(Handler handler); @@ -120,6 +135,26 @@ public: BOOST_ASIO_DECL void post_deferred_completions( op_queue<win_iocp_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. + void post_private_immediate_completion(win_iocp_operation* op) + { + post_immediate_completion(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. + void post_private_deferred_completion(win_iocp_operation* op) + { + post_deferred_completion(op); + } + + // Process unfinished operations as part of a shutdown_service operation. + // Assumes that work_started() was previously called for the operations. + BOOST_ASIO_DECL void abandon_operations(op_queue<operation>& ops); + // Called after starting an overlapped I/O operation that did not complete // immediately. The caller must have already called work_started() prior to // starting the operation. @@ -150,13 +185,14 @@ public: template <typename Time_Traits> 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); + typename timer_queue<Time_Traits>::per_timer_data& timer, wait_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>& queue, - typename timer_queue<Time_Traits>::per_timer_data& timer); + typename timer_queue<Time_Traits>::per_timer_data& timer, + std::size_t max_cancelled = (std::numeric_limits<std::size_t>::max)()); private: #if defined(WINVER) && (WINVER < 0x0500) @@ -199,7 +235,7 @@ private: long outstanding_work_; // Flag to indicate whether the event loop has been stopped. - long stopped_; + mutable long stopped_; // Flag to indicate whether the service has been shut down. long shutdown_; @@ -233,7 +269,7 @@ private: friend struct timer_thread_function; // Background thread used for processing timeouts. - boost::scoped_ptr<thread> timer_thread_; + scoped_ptr<thread> timer_thread_; // A waitable timer object used for waiting for timeouts. auto_handle waitable_timer_; |