这篇教程C++ ASIO_HANDLER_COMPLETION函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中ASIO_HANDLER_COMPLETION函数的典型用法代码示例。如果您正苦于以下问题:C++ ASIO_HANDLER_COMPLETION函数的具体用法?C++ ASIO_HANDLER_COMPLETION怎么用?C++ ASIO_HANDLER_COMPLETION使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了ASIO_HANDLER_COMPLETION函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: do_complete static void do_complete(io_service_impl* owner, operation* base, asio::error_code /*ec*/, std::size_t /*bytes_transferred*/) { // Take ownership of the handler object. wait_handler* h(static_cast<wait_handler*>(base)); ptr p = { boost::addressof(h->handler_), h, h }; ASIO_HANDLER_COMPLETION((h)); // 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::binder1<Handler, asio::error_code> handler(h->handler_, h->ec_); p.h = boost::addressof(handler.handler_); p.reset(); // Make the upcall if required. if (owner) { asio::detail::fenced_block b; ASIO_HANDLER_INVOCATION_BEGIN((handler.arg1_)); asio_handler_invoke_helpers::invoke(handler, handler.handler_); ASIO_HANDLER_INVOCATION_END; } }
开发者ID:Almamu,项目名称:evemu_crucible,代码行数:29,
示例2: do_complete static void do_complete(void* owner, operation* base, const asio::error_code& ec, std::size_t bytes_transferred) { // Take ownership of the operation object. win_iocp_overlapped_op* o(static_cast<win_iocp_overlapped_op*>(base)); ptr p = { asio::detail::addressof(o->handler_), o, o }; handler_work<Handler> w(o->handler_); ASIO_HANDLER_COMPLETION((*o)); // 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, asio::error_code, std::size_t> handler(o->handler_, ec, bytes_transferred); p.h = asio::detail::addressof(handler.handler_); p.reset(); // Make the upcall if required. if (owner) { fenced_block b(fenced_block::half); ASIO_HANDLER_INVOCATION_BEGIN((handler.arg1_, handler.arg2_)); w.complete(handler, handler.handler_); ASIO_HANDLER_INVOCATION_END; } }
开发者ID:damu,项目名称:asio,代码行数:30,
示例3: do_complete static void do_complete(void* owner, Operation* base, const asio::error_code& /*ec*/, std::size_t /*bytes_transferred*/) { // Take ownership of the handler object. executor_op* o(static_cast<executor_op*>(base)); ptr p = { o->allocator_, o, o }; ASIO_HANDLER_COMPLETION((o)); // 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. Handler handler(ASIO_MOVE_CAST(Handler)(o->handler_)); p.reset(); // Make the upcall if required. if (owner) { fenced_block b(fenced_block::half); ASIO_HANDLER_INVOCATION_BEGIN(()); asio_handler_invoke_helpers::invoke(handler, handler); ASIO_HANDLER_INVOCATION_END; } }
开发者ID:DevSlashNull,项目名称:MaidSafe,代码行数:28,
示例4: do_complete static void do_complete(void* owner, operation* base, const asio::error_code& /*ec*/, std::size_t /*bytes_transferred*/) { // Take ownership of the handler object. completion_handler* h(static_cast<completion_handler*>(base)); ptr p = { asio::detail::addressof(h->handler_), h, h }; handler_work<Handler> w(h->handler_); ASIO_HANDLER_COMPLETION((h)); // 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. Handler handler(ASIO_MOVE_CAST(Handler)(h->handler_)); p.h = asio::detail::addressof(handler); p.reset(); // Make the upcall if required. if (owner) { fenced_block b(fenced_block::half); ASIO_HANDLER_INVOCATION_BEGIN(()); w.complete(handler, handler); ASIO_HANDLER_INVOCATION_END; } }
开发者ID:DevSlashNull,项目名称:MaidSafe,代码行数:30,
示例5: do_complete static void do_complete(void* owner, operation* base, const asio::error_code& /*ec*/, std::size_t /*bytes_transferred*/) { // Take ownership of the operation object. resolve_op* o(static_cast<resolve_op*>(base)); ptr p = { asio::detail::addressof(o->handler_), o, o }; handler_work<Handler> w(o->handler_); if (owner && owner != &o->io_context_impl_) { // The operation is being run on the worker io_context. Time to perform // the resolver operation. // Perform the blocking host resolution operation. socket_ops::background_getaddrinfo(o->cancel_token_, o->query_.host_name().c_str(), o->query_.service_name().c_str(), o->query_.hints(), &o->addrinfo_, o->ec_); // Pass operation back to main io_context for completion. o->io_context_impl_.post_deferred_completion(o); p.v = p.p = 0; } else { // The operation has been returned to the main io_context. The completion // handler is ready to be delivered. ASIO_HANDLER_COMPLETION((*o)); // 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, asio::error_code, results_type> handler(o->handler_, o->ec_, results_type()); p.h = asio::detail::addressof(handler.handler_); if (o->addrinfo_) { handler.arg2_ = results_type::create(o->addrinfo_, o->query_.host_name(), o->query_.service_name()); } p.reset(); if (owner) { fenced_block b(fenced_block::half); ASIO_HANDLER_INVOCATION_BEGIN((handler.arg1_, "...")); w.complete(handler, handler.handler_); ASIO_HANDLER_INVOCATION_END; } } }
开发者ID:blockchain-research-foundation,项目名称:openmonero,代码行数:55,
示例6: do_complete static void do_complete( io_service_impl* owner, operation* base, const asio::error_code& /*ec*/, std::size_t /*bytes_transferred*/ ) { // Take ownership of the operation object. resolve_endpoint_op* o( static_cast<resolve_endpoint_op*>( base ) ); ptr p = {asio::detail::addressof( o->handler_ ), o, o}; if ( owner && owner != &o->io_service_impl_ ) { // The operation is being run on the worker io_service. Time to perform // the resolver operation. // Perform the blocking endpoint resolution operation. char host_name[NI_MAXHOST]; char service_name[NI_MAXSERV]; socket_ops::background_getnameinfo( o->cancel_token_, o->endpoint_.data( ), o->endpoint_.size( ), host_name, NI_MAXHOST, service_name, NI_MAXSERV, o->endpoint_.protocol( ).type( ), o->ec_ ); o->iter_ = iterator_type::create( o->endpoint_, host_name, service_name ); // Pass operation back to main io_service for completion. o->io_service_impl_.post_deferred_completion( o ); p.v = p.p = 0; } else { // The operation has been returned to the main io_service. The completion // handler is ready to be delivered. ASIO_HANDLER_COMPLETION( ( o ) ); // 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, asio::error_code, iterator_type> handler( o->handler_, o->ec_, o->iter_ ); p.h = asio::detail::addressof( handler.handler_ ); p.reset( ); if ( owner ) { fenced_block b( fenced_block::half ); ASIO_HANDLER_INVOCATION_BEGIN( ( handler.arg1_, "..." ) ); asio_handler_invoke_helpers::invoke( handler, handler.handler_ ); ASIO_HANDLER_INVOCATION_END; } } }
开发者ID:obergner,项目名称:wally-io,代码行数:52,
示例7: do_complete static void do_complete(void* owner, operation* base, const asio::error_code& result_ec, std::size_t bytes_transferred) { asio::error_code ec(result_ec); // Take ownership of the operation object. win_iocp_null_buffers_op* o(static_cast<win_iocp_null_buffers_op*>(base)); ptr p = { asio::detail::addressof(o->handler_), o, o }; handler_work<Handler> w(o->handler_); ASIO_HANDLER_COMPLETION((*o)); // The reactor may have stored a result in the operation object. if (o->ec_) ec = o->ec_; // Map non-portable errors to their portable counterparts. if (ec.value() == ERROR_NETNAME_DELETED) { if (o->cancel_token_.expired()) ec = asio::error::operation_aborted; else ec = asio::error::connection_reset; } else if (ec.value() == ERROR_PORT_UNREACHABLE) { ec = asio::error::connection_refused; } // 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, asio::error_code, std::size_t> handler(o->handler_, ec, bytes_transferred); p.h = asio::detail::addressof(handler.handler_); p.reset(); // Make the upcall if required. if (owner) { fenced_block b(fenced_block::half); ASIO_HANDLER_INVOCATION_BEGIN((handler.arg1_, handler.arg2_)); w.complete(handler, handler.handler_); ASIO_HANDLER_INVOCATION_END; } }
开发者ID:damu,项目名称:asio,代码行数:50,
示例8: do_complete static void do_complete(void* owner, operation* base, const asio::error_code& result_ec, std::size_t bytes_transferred) { asio::error_code ec(result_ec); // Take ownership of the operation object. win_iocp_socket_recvfrom_op* o( static_cast<win_iocp_socket_recvfrom_op*>(base)); ptr p = { asio::detail::addressof(o->handler_), o, o }; handler_work<Handler> w(o->handler_); ASIO_HANDLER_COMPLETION((o));#if defined(ASIO_ENABLE_BUFFER_DEBUGGING) // Check whether buffers are still valid. if (owner) { buffer_sequence_adapter<asio::mutable_buffer, MutableBufferSequence>::validate(o->buffers_); }#endif // defined(ASIO_ENABLE_BUFFER_DEBUGGING) socket_ops::complete_iocp_recvfrom(o->cancel_token_, ec); // Record the size of the endpoint returned by the operation. o->endpoint_.resize(o->endpoint_size_); // 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, asio::error_code, std::size_t> handler(o->handler_, ec, bytes_transferred); p.h = asio::detail::addressof(handler.handler_); p.reset(); // Make the upcall if required. if (owner) { fenced_block b(fenced_block::half); ASIO_HANDLER_INVOCATION_BEGIN((handler.arg1_, handler.arg2_)); w.complete(handler, handler.handler_); ASIO_HANDLER_INVOCATION_END; } }
开发者ID:Ahbee,项目名称:Cinder,代码行数:48,
示例9: do_complete static void do_complete(void* owner, operation* base, const asio::error_code& result_ec, std::size_t bytes_transferred) { asio::error_code ec(result_ec); // Take ownership of the operation object. win_iocp_handle_read_op* o(static_cast<win_iocp_handle_read_op*>(base)); ptr p = { asio::detail::addressof(o->handler_), o, o }; handler_work<Handler, IoExecutor> w(o->handler_, o->io_executor_); ASIO_HANDLER_COMPLETION((*o));#if defined(ASIO_ENABLE_BUFFER_DEBUGGING) if (owner) { // Check whether buffers are still valid. buffer_sequence_adapter<asio::mutable_buffer, MutableBufferSequence>::validate(o->buffers_); }#endif // defined(ASIO_ENABLE_BUFFER_DEBUGGING) // Map non-portable errors to their portable counterparts. if (ec.value() == ERROR_HANDLE_EOF) ec = asio::error::eof; // 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, asio::error_code, std::size_t> handler(o->handler_, ec, bytes_transferred); p.h = asio::detail::addressof(handler.handler_); p.reset(); // Make the upcall if required. if (owner) { fenced_block b(fenced_block::half); ASIO_HANDLER_INVOCATION_BEGIN((handler.arg1_, handler.arg2_)); w.complete(handler, handler.handler_); ASIO_HANDLER_INVOCATION_END; } }
开发者ID:DitansKing,项目名称:asio,代码行数:46,
示例10: do_complete static void do_complete(io_service_impl* owner, operation* base, asio::error_code ec, std::size_t bytes_transferred) { // Take ownership of the operation object. win_iocp_socket_recv_op* o(static_cast<win_iocp_socket_recv_op*>(base)); ptr p = { boost::addressof(o->handler_), o, o }; ASIO_HANDLER_COMPLETION((o));#if defined(ASIO_ENABLE_BUFFER_DEBUGGING) // Check whether buffers are still valid. if (owner) { buffer_sequence_adapter<asio::mutable_buffer, MutableBufferSequence>::validate(o->buffers_); }#endif // defined(ASIO_ENABLE_BUFFER_DEBUGGING) socket_ops::complete_iocp_recv(o->state_, o->cancel_token_, buffer_sequence_adapter<asio::mutable_buffer, MutableBufferSequence>::all_empty(o->buffers_), ec, bytes_transferred); // 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, asio::error_code, std::size_t> handler(o->handler_, ec, bytes_transferred); p.h = boost::addressof(handler.handler_); p.reset(); // Make the upcall if required. if (owner) { asio::detail::fenced_block b; ASIO_HANDLER_INVOCATION_BEGIN((handler.arg1_, handler.arg2_)); asio_handler_invoke_helpers::invoke(handler, handler.handler_); ASIO_HANDLER_INVOCATION_END; } }
开发者ID:Almamu,项目名称:evemu_crucible,代码行数:43,
示例11: do_complete static void do_complete(void* owner, operation* base, const asio::error_code& result_ec, std::size_t /*bytes_transferred*/) { asio::error_code ec(result_ec); // Take ownership of the operation object. win_iocp_socket_accept_op* o(static_cast<win_iocp_socket_accept_op*>(base)); ptr p = { asio::detail::addressof(o->handler_), o, o }; handler_work<Handler> w(o->handler_); if (owner) { typename Protocol::endpoint peer_endpoint; std::size_t addr_len = peer_endpoint.capacity(); socket_ops::complete_iocp_accept(o->socket_, o->output_buffer(), o->address_length(), peer_endpoint.data(), &addr_len, o->new_socket_.get(), ec); // Restart the accept operation if we got the connection_aborted error // and the enable_connection_aborted socket option is not set. if (ec == asio::error::connection_aborted && !o->enable_connection_aborted_) { o->reset(); o->socket_service_.restart_accept_op(o->socket_, o->new_socket_, o->protocol_.family(), o->protocol_.type(), o->protocol_.protocol(), o->output_buffer(), o->address_length(), o); p.v = p.p = 0; return; } // If the socket was successfully accepted, transfer ownership of the // socket to the peer object. if (!ec) { o->peer_.assign(o->protocol_, typename Socket::native_handle_type( o->new_socket_.get(), peer_endpoint), ec); if (!ec) o->new_socket_.release(); } // Pass endpoint back to caller. if (o->peer_endpoint_) *o->peer_endpoint_ = peer_endpoint; } ASIO_HANDLER_COMPLETION((*o)); // 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::binder1<Handler, asio::error_code> handler(o->handler_, ec); p.h = asio::detail::addressof(handler.handler_); p.reset(); // Make the upcall if required. if (owner) { fenced_block b(fenced_block::half); ASIO_HANDLER_INVOCATION_BEGIN((handler.arg1_)); w.complete(handler, handler.handler_); ASIO_HANDLER_INVOCATION_END; } }
开发者ID:Aulddays,项目名称:APass,代码行数:72,
注:本文中的ASIO_HANDLER_COMPLETION函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ ASIO_MOVE_ARG函数代码示例 C++ ASIC_IS_DCE4函数代码示例 |