diff options
Diffstat (limited to '3rdParty/Boost/src/boost/asio/detail/impl/win_iocp_handle_service.ipp')
-rw-r--r-- | 3rdParty/Boost/src/boost/asio/detail/impl/win_iocp_handle_service.ipp | 86 |
1 files changed, 79 insertions, 7 deletions
diff --git a/3rdParty/Boost/src/boost/asio/detail/impl/win_iocp_handle_service.ipp b/3rdParty/Boost/src/boost/asio/detail/impl/win_iocp_handle_service.ipp index eb6643a..ecd45c0 100644 --- a/3rdParty/Boost/src/boost/asio/detail/impl/win_iocp_handle_service.ipp +++ b/3rdParty/Boost/src/boost/asio/detail/impl/win_iocp_handle_service.ipp @@ -2,7 +2,7 @@ // detail/impl/win_iocp_handle_service.ipp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) // Copyright (c) 2008 Rep Invariant Systems, Inc. (info@repinvariant.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -100,6 +100,64 @@ void win_iocp_handle_service::construct( impl_list_ = &impl; } +void win_iocp_handle_service::move_construct( + win_iocp_handle_service::implementation_type& impl, + win_iocp_handle_service::implementation_type& other_impl) +{ + impl.handle_ = other_impl.handle_; + other_impl.handle_ = INVALID_HANDLE_VALUE; + + impl.safe_cancellation_thread_id_ = other_impl.safe_cancellation_thread_id_; + other_impl.safe_cancellation_thread_id_ = 0; + + // Insert implementation into linked list of all implementations. + boost::asio::detail::mutex::scoped_lock lock(mutex_); + impl.next_ = impl_list_; + impl.prev_ = 0; + if (impl_list_) + impl_list_->prev_ = &impl; + impl_list_ = &impl; +} + +void win_iocp_handle_service::move_assign( + win_iocp_handle_service::implementation_type& impl, + win_iocp_handle_service& other_service, + win_iocp_handle_service::implementation_type& other_impl) +{ + close_for_destruction(impl); + + if (this != &other_service) + { + // Remove implementation from linked list of all implementations. + boost::asio::detail::mutex::scoped_lock lock(mutex_); + if (impl_list_ == &impl) + impl_list_ = impl.next_; + if (impl.prev_) + impl.prev_->next_ = impl.next_; + if (impl.next_) + impl.next_->prev_= impl.prev_; + impl.next_ = 0; + impl.prev_ = 0; + } + + impl.handle_ = other_impl.handle_; + other_impl.handle_ = INVALID_HANDLE_VALUE; + + impl.safe_cancellation_thread_id_ = other_impl.safe_cancellation_thread_id_; + other_impl.safe_cancellation_thread_id_ = 0; + + if (this != &other_service) + { + // Insert implementation into linked list of all implementations. + boost::asio::detail::mutex::scoped_lock lock(other_service.mutex_); + impl.next_ = other_service.impl_list_; + impl.prev_ = 0; + if (other_service.impl_list_) + other_service.impl_list_->prev_ = &impl; + other_service.impl_list_ = &impl; + } +} + void win_iocp_handle_service::destroy( win_iocp_handle_service::implementation_type& impl) { @@ -119,7 +177,7 @@ void win_iocp_handle_service::destroy( boost::system::error_code win_iocp_handle_service::assign( win_iocp_handle_service::implementation_type& impl, - const native_type& native_handle, boost::system::error_code& ec) + const native_handle_type& handle, boost::system::error_code& ec) { if (is_open(impl)) { @@ -127,10 +185,10 @@ boost::system::error_code win_iocp_handle_service::assign( return ec; } - if (iocp_service_.register_handle(native_handle, ec)) + if (iocp_service_.register_handle(handle, ec)) return ec; - impl.handle_ = native_handle; + impl.handle_ = handle; ec = boost::system::error_code(); return ec; } @@ -141,19 +199,27 @@ boost::system::error_code win_iocp_handle_service::close( { if (is_open(impl)) { + BOOST_ASIO_HANDLER_OPERATION(("handle", &impl, "close")); + if (!::CloseHandle(impl.handle_)) { DWORD last_error = ::GetLastError(); ec = boost::system::error_code(last_error, boost::asio::error::get_system_category()); - return ec; + } + else + { + ec = boost::system::error_code(); } impl.handle_ = INVALID_HANDLE_VALUE; impl.safe_cancellation_thread_id_ = 0; } + else + { + ec = boost::system::error_code(); + } - ec = boost::system::error_code(); return ec; } @@ -164,8 +230,12 @@ boost::system::error_code win_iocp_handle_service::cancel( if (!is_open(impl)) { ec = boost::asio::error::bad_descriptor; + return ec; } - else if (FARPROC cancel_io_ex_ptr = ::GetProcAddress( + + BOOST_ASIO_HANDLER_OPERATION(("handle", &impl, "cancel")); + + if (FARPROC cancel_io_ex_ptr = ::GetProcAddress( ::GetModuleHandleA("KERNEL32"), "CancelIoEx")) { // The version of Windows supports cancellation from any thread. @@ -437,6 +507,8 @@ void win_iocp_handle_service::close_for_destruction(implementation_type& impl) { if (is_open(impl)) { + BOOST_ASIO_HANDLER_OPERATION(("handle", &impl, "close")); + ::CloseHandle(impl.handle_); impl.handle_ = INVALID_HANDLE_VALUE; impl.safe_cancellation_thread_id_ = 0; |