annotate DEPENDENCIES/generic/include/boost/asio/windows/overlapped_ptr.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 //
Chris@16 2 // windows/overlapped_ptr.hpp
Chris@16 3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~
Chris@16 4 //
Chris@101 5 // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
Chris@16 6 //
Chris@16 7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
Chris@16 8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 9 //
Chris@16 10
Chris@16 11 #ifndef BOOST_ASIO_WINDOWS_OVERLAPPED_PTR_HPP
Chris@16 12 #define BOOST_ASIO_WINDOWS_OVERLAPPED_PTR_HPP
Chris@16 13
Chris@16 14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
Chris@16 15 # pragma once
Chris@16 16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
Chris@16 17
Chris@16 18 #include <boost/asio/detail/config.hpp>
Chris@16 19
Chris@16 20 #if defined(BOOST_ASIO_HAS_WINDOWS_OVERLAPPED_PTR) \
Chris@16 21 || defined(GENERATING_DOCUMENTATION)
Chris@16 22
Chris@16 23 #include <boost/asio/detail/noncopyable.hpp>
Chris@16 24 #include <boost/asio/detail/win_iocp_overlapped_ptr.hpp>
Chris@16 25 #include <boost/asio/io_service.hpp>
Chris@16 26
Chris@16 27 #include <boost/asio/detail/push_options.hpp>
Chris@16 28
Chris@16 29 namespace boost {
Chris@16 30 namespace asio {
Chris@16 31 namespace windows {
Chris@16 32
Chris@16 33 /// Wraps a handler to create an OVERLAPPED object for use with overlapped I/O.
Chris@16 34 /**
Chris@16 35 * A special-purpose smart pointer used to wrap an application handler so that
Chris@16 36 * it can be passed as the LPOVERLAPPED argument to overlapped I/O functions.
Chris@16 37 *
Chris@16 38 * @par Thread Safety
Chris@16 39 * @e Distinct @e objects: Safe.@n
Chris@16 40 * @e Shared @e objects: Unsafe.
Chris@16 41 */
Chris@16 42 class overlapped_ptr
Chris@16 43 : private noncopyable
Chris@16 44 {
Chris@16 45 public:
Chris@16 46 /// Construct an empty overlapped_ptr.
Chris@16 47 overlapped_ptr()
Chris@16 48 : impl_()
Chris@16 49 {
Chris@16 50 }
Chris@16 51
Chris@16 52 /// Construct an overlapped_ptr to contain the specified handler.
Chris@16 53 template <typename Handler>
Chris@16 54 explicit overlapped_ptr(boost::asio::io_service& io_service,
Chris@16 55 BOOST_ASIO_MOVE_ARG(Handler) handler)
Chris@16 56 : impl_(io_service, BOOST_ASIO_MOVE_CAST(Handler)(handler))
Chris@16 57 {
Chris@16 58 }
Chris@16 59
Chris@16 60 /// Destructor automatically frees the OVERLAPPED object unless released.
Chris@16 61 ~overlapped_ptr()
Chris@16 62 {
Chris@16 63 }
Chris@16 64
Chris@16 65 /// Reset to empty.
Chris@16 66 void reset()
Chris@16 67 {
Chris@16 68 impl_.reset();
Chris@16 69 }
Chris@16 70
Chris@16 71 /// Reset to contain the specified handler, freeing any current OVERLAPPED
Chris@16 72 /// object.
Chris@16 73 template <typename Handler>
Chris@16 74 void reset(boost::asio::io_service& io_service,
Chris@16 75 BOOST_ASIO_MOVE_ARG(Handler) handler)
Chris@16 76 {
Chris@16 77 impl_.reset(io_service, BOOST_ASIO_MOVE_CAST(Handler)(handler));
Chris@16 78 }
Chris@16 79
Chris@16 80 /// Get the contained OVERLAPPED object.
Chris@16 81 OVERLAPPED* get()
Chris@16 82 {
Chris@16 83 return impl_.get();
Chris@16 84 }
Chris@16 85
Chris@16 86 /// Get the contained OVERLAPPED object.
Chris@16 87 const OVERLAPPED* get() const
Chris@16 88 {
Chris@16 89 return impl_.get();
Chris@16 90 }
Chris@16 91
Chris@16 92 /// Release ownership of the OVERLAPPED object.
Chris@16 93 OVERLAPPED* release()
Chris@16 94 {
Chris@16 95 return impl_.release();
Chris@16 96 }
Chris@16 97
Chris@16 98 /// Post completion notification for overlapped operation. Releases ownership.
Chris@16 99 void complete(const boost::system::error_code& ec,
Chris@16 100 std::size_t bytes_transferred)
Chris@16 101 {
Chris@16 102 impl_.complete(ec, bytes_transferred);
Chris@16 103 }
Chris@16 104
Chris@16 105 private:
Chris@16 106 detail::win_iocp_overlapped_ptr impl_;
Chris@16 107 };
Chris@16 108
Chris@16 109 } // namespace windows
Chris@16 110 } // namespace asio
Chris@16 111 } // namespace boost
Chris@16 112
Chris@16 113 #include <boost/asio/detail/pop_options.hpp>
Chris@16 114
Chris@16 115 #endif // defined(BOOST_ASIO_HAS_WINDOWS_OVERLAPPED_PTR)
Chris@16 116 // || defined(GENERATING_DOCUMENTATION)
Chris@16 117
Chris@16 118 #endif // BOOST_ASIO_WINDOWS_OVERLAPPED_PTR_HPP