summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '3rdParty/Boost/src/boost/asio/detail/win_iocp_overlapped_ptr.hpp')
-rw-r--r--3rdParty/Boost/src/boost/asio/detail/win_iocp_overlapped_ptr.hpp70
1 files changed, 18 insertions, 52 deletions
diff --git a/3rdParty/Boost/src/boost/asio/detail/win_iocp_overlapped_ptr.hpp b/3rdParty/Boost/src/boost/asio/detail/win_iocp_overlapped_ptr.hpp
index 082a5b1..5589c11 100644
--- a/3rdParty/Boost/src/boost/asio/detail/win_iocp_overlapped_ptr.hpp
+++ b/3rdParty/Boost/src/boost/asio/detail/win_iocp_overlapped_ptr.hpp
@@ -1,6 +1,6 @@
//
-// win_iocp_overlapped_ptr.hpp
-// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// detail/win_iocp_overlapped_ptr.hpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
@@ -15,16 +15,18 @@
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
-#include <boost/asio/detail/push_options.hpp>
-
-#include <boost/asio/detail/win_iocp_io_service_fwd.hpp>
+#include <boost/asio/detail/config.hpp>
#if defined(BOOST_ASIO_HAS_IOCP)
-#include <boost/asio/detail/fenced_block.hpp>
+#include <boost/utility/addressof.hpp>
+#include <boost/asio/io_service.hpp>
+#include <boost/asio/detail/handler_alloc_helpers.hpp>
#include <boost/asio/detail/noncopyable.hpp>
+#include <boost/asio/detail/win_iocp_overlapped_op.hpp>
#include <boost/asio/detail/win_iocp_io_service.hpp>
-#include <boost/asio/detail/win_iocp_operation.hpp>
+
+#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
@@ -75,13 +77,15 @@ public:
template <typename Handler>
void reset(boost::asio::io_service& io_service, Handler handler)
{
- typedef overlapped_op<Handler> value_type;
- typedef handler_alloc_traits<Handler, value_type> alloc_traits;
- raw_handler_ptr<alloc_traits> raw_ptr(handler);
- handler_ptr<alloc_traits> ptr(raw_ptr, handler);
+ typedef win_iocp_overlapped_op<Handler> op;
+ typename op::ptr p = { boost::addressof(handler),
+ boost_asio_handler_alloc_helpers::allocate(
+ sizeof(op), handler), 0 };
+ p.p = new (p.v) op(handler);
io_service.impl_.work_started();
reset();
- ptr_ = ptr.release();
+ ptr_ = p.p;
+ p.v = p.p = 0;
iocp_service_ = &io_service.impl_;
}
@@ -123,44 +127,6 @@ public:
}
private:
- template <typename Handler>
- struct overlapped_op : public win_iocp_operation
- {
- overlapped_op(Handler handler)
- : win_iocp_operation(&overlapped_op::do_complete),
- handler_(handler)
- {
- }
-
- static void do_complete(io_service_impl* owner, operation* base,
- boost::system::error_code ec, std::size_t bytes_transferred)
- {
- // Take ownership of the operation object.
- overlapped_op* o(static_cast<overlapped_op*>(base));
- typedef handler_alloc_traits<Handler, overlapped_op> alloc_traits;
- handler_ptr<alloc_traits> ptr(o->handler_, o);
-
- // Make the upcall if required.
- if (owner)
- {
- // Make a copy of the handler so that the memory can be deallocated
- // before the upcall is made. Even if we're not about to make an
- // upcall, a sub-object of the handler may be the true owner of the
- // memory associated with the handler. Consequently, a local copy of
- // the handler is required to ensure that any owning sub-object remains
- // valid until after we have deallocated the memory here.
- detail::binder2<Handler, boost::system::error_code, std::size_t>
- handler(o->handler_, ec, bytes_transferred);
- ptr.reset();
- boost::asio::detail::fenced_block b;
- boost_asio_handler_invoke_helpers::invoke(handler, handler);
- }
- }
-
- private:
- Handler handler_;
- };
-
win_iocp_operation* ptr_;
win_iocp_io_service* iocp_service_;
};
@@ -169,8 +135,8 @@ private:
} // namespace asio
} // namespace boost
-#endif // defined(BOOST_ASIO_HAS_IOCP)
-
#include <boost/asio/detail/pop_options.hpp>
+#endif // defined(BOOST_ASIO_HAS_IOCP)
+
#endif // BOOST_ASIO_DETAIL_WIN_IOCP_OVERLAPPED_PTR_HPP