本文整理匯總了C++中BOOST_ASIO_MOVE_ARG函數的典型用法代碼示例。如果您正苦於以下問題:C++ BOOST_ASIO_MOVE_ARG函數的具體用法?C++ BOOST_ASIO_MOVE_ARG怎麽用?C++ BOOST_ASIO_MOVE_ARG使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了BOOST_ASIO_MOVE_ARG函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: basic_yield_context
namespace asio {
template< typename Handler >
class basic_yield_context {
public:
basic_yield_context(
boost::fibers::context * ctx,
Handler& handler) :
ctx_( ctx),
handler_( handler),
ec_( 0) {
}
basic_yield_context operator[]( boost::system::error_code & ec) {
basic_yield_context tmp( * this);
tmp.ec_ = & ec;
return tmp;
}
private:
boost::fibers::context * ctx_;
Handler & handler_;
boost::system::error_code * ec_;
};
typedef basic_yield_context<
boost::asio::detail::wrapped_handler<
boost::asio::io_service::strand, void(*)(),
boost::asio::detail::is_continuation_if_running> > yield_context;
template< typename Handler, typename Function >
void spawn( boost::asio::io_service & io_service,
BOOST_ASIO_MOVE_ARG( Handler) handler,
BOOST_ASIO_MOVE_ARG( Function) function);
template< typename Handler, typename Function >
void spawn( boost::asio::io_service & io_service,
basic_yield_context< Handler > ctx,
BOOST_ASIO_MOVE_ARG( Function) function);
template< typename Function >
void spawn( boost::asio::io_service::strand strand,
BOOST_ASIO_MOVE_ARG( Function) function);
template< typename Function >
void spawn( boost::asio::io_service & io_service,
BOOST_ASIO_MOVE_ARG( Function) function);
}}}
示例2: async_accept
async_accept(basic_socket<Protocol1, SocketService>& peer,
BOOST_ASIO_MOVE_ARG(AcceptHandler) handler,
typename enable_if<is_convertible<Protocol, Protocol1>::value>::type* = 0)
{
// If you get an error on the following line it means that your handler does
// not meet the documented type requirements for a AcceptHandler.
BOOST_ASIO_ACCEPT_HANDLER_CHECK(AcceptHandler, handler) type_check;
return this->get_service().async_accept(this->get_implementation(),
peer, static_cast<endpoint_type*>(0),
BOOST_ASIO_MOVE_CAST(AcceptHandler)(handler));
}
示例3: async_accept
async_accept(implementation_type& impl,
basic_socket<Protocol1, SocketService>& peer,
endpoint_type* peer_endpoint,
BOOST_ASIO_MOVE_ARG(AcceptHandler) handler,
typename enable_if<
is_convertible<Protocol, Protocol1>::value>::type* = 0) {
boost::asio::detail::async_result_init<AcceptHandler,
void(boost::system::error_code)>
init(BOOST_ASIO_MOVE_CAST(AcceptHandler)(handler));
{
boost::recursive_mutex::scoped_lock lock_state(impl->state_mutex);
if (impl->closed) {
auto handler_to_post = [init]() mutable {
init.handler(
boost::system::error_code(ssf::error::not_connected,
ssf::error::get_ssf_category()));
};
this->get_io_service().post(handler_to_post);
return init.result.get();
}
}
boost::system::error_code ec;
auto fiber_impl = peer.native_handle();
fiber_impl->p_fib_demux = impl->p_fib_demux;
fiber_impl->id.set_local_port(impl->id.local_port());
BOOST_LOG_TRIVIAL(debug) << "fiber acceptor: local port set " << impl->id.local_port();
typedef detail::pending_accept_operation<
AcceptHandler, typename Protocol::socket_type> op;
typename op::ptr p = {
boost::asio::detail::addressof(init.handler),
boost_asio_handler_alloc_helpers::allocate(sizeof(op), init.handler),
0};
p.p = new (p.v)
op(peer.native_handle(), &(peer.native_handle()->id), init.handler);
{
boost::recursive_mutex::scoped_lock lock(impl->accept_op_queue_mutex);
impl->accept_op_queue.push(p.p);
}
p.v = p.p = 0;
impl->a_queues_handler();
return init.result.get();
}
示例4: async_receive_header
// @end code
// @begin example
// void receive_header_handler(const boost::system::error_code& ec)
// {
// if (!ec)
// {
// // 請求成功!
// }
// }
// ...
// avhttp::http_stream h(io_service);
// ...
// h.async_recvive_header(boost::bind(&receive_header_handler, boost::asio::placeholders::error));
// @end example
template <typename Handler>
void async_receive_header(BOOST_ASIO_MOVE_ARG(Handler) handler);
///清除讀寫緩衝區數據.
// @備注: 非線程安全! 不應在正在進行讀寫操作時進行該操作!
AVHTTP_DECL void clear();
///關閉http_stream.
// @失敗拋出asio::system_error異常.
// @備注: 停止所有正在進行的讀寫操作, 正在進行的異步調用將回調
// boost::asio::error::operation_aborted錯誤.
AVHTTP_DECL void close();
///關閉http_stream.
// @param ec保存失敗信息.
// @備注: 停止所有正在進行的讀寫操作, 正在進行的異步調用將回調
// boost::asio::error::operation_aborted錯誤.
示例5: wait
{
return service_impl_.cancel(impl, ec);
}
// Wait for a signaled state.
void wait(implementation_type& impl, boost::system::error_code& ec)
{
service_impl_.wait(impl, ec);
}
/// Start an asynchronous wait.
template <typename WaitHandler>
BOOST_ASIO_INITFN_RESULT_TYPE(WaitHandler,
void (boost::system::error_code))
async_wait(implementation_type& impl,
BOOST_ASIO_MOVE_ARG(WaitHandler) handler)
{
boost::asio::detail::async_result_init<
WaitHandler, void (boost::system::error_code)> init(
BOOST_ASIO_MOVE_CAST(WaitHandler)(handler));
service_impl_.async_wait(impl, init.handler);
return init.result.get();
}
private:
// Destroy all user-defined handler objects owned by the service.
void shutdown_service()
{
service_impl_.shutdown_service();
示例6: BOOST_ASIO_INITFN_RESULT_TYPE
* not, the handler will not be invoked from within this function. Invocation of
* the handler will be performed in a manner equivalent to using
* boost::asio::io_service::post().
*
* @note This overload is equivalent to calling:
* @code boost::asio::async_read_at(
* d, 42, b,
* boost::asio::transfer_all(),
* handler); @endcode
*/
template <typename AsyncRandomAccessReadDevice, typename Allocator,
typename ReadHandler>
BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
void (boost::system::error_code, std::size_t))
async_read_at(AsyncRandomAccessReadDevice& d, uint64_t offset,
basic_streambuf<Allocator>& b, BOOST_ASIO_MOVE_ARG(ReadHandler) handler);
/// Start an asynchronous operation to read a certain amount of data at the
/// specified offset.
/**
* This function is used to asynchronously read a certain number of bytes of
* data from a random access device at the specified offset. The function call
* always returns immediately. The asynchronous operation will continue until
* one of the following conditions is true:
*
* @li The completion_condition function object returns 0.
*
* This operation is implemented in terms of zero or more calls to the device's
* async_read_some_at function.
*
* @param d The device from which the data is to be read. The type must support
示例7: BOOST_ASIO_INITFN_RESULT_TYPE
*
* @param type The type of handshaking to be performed, i.e. as a client or as
* a server.
*
* @param handler The handler to be called when the handshake operation
* completes. Copies will be made of the handler as required. The equivalent
* function signature of the handler must be:
* @code void handler(
* const boost::system::error_code& error // Result of operation.
* ); @endcode
*/
template <typename HandshakeHandler>
BOOST_ASIO_INITFN_RESULT_TYPE(HandshakeHandler,
void (boost::system::error_code))
async_handshake(handshake_type type,
BOOST_ASIO_MOVE_ARG(HandshakeHandler) handler)
{
// If you get an error on the following line it means that your handler does
// not meet the documented type requirements for a HandshakeHandler.
BOOST_ASIO_HANDSHAKE_HANDLER_CHECK(HandshakeHandler, handler) type_check;
boost::asio::detail::async_result_init<
HandshakeHandler, void (boost::system::error_code)> init(
BOOST_ASIO_MOVE_CAST(HandshakeHandler)(handler));
detail::async_io(next_layer_, core_,
detail::handshake_op(type), init.handler);
return init.result.get();
}
示例8: spawn
/// completes.
/**
* This function is used to launch a new coroutine.
*
* @param handler A handler to be called when the coroutine exits. More
* importantly, the handler provides an execution context (via the the handler
* invocation hook) for the coroutine. The handler must have the signature:
* @code void handler(); @endcode
*
* @param function The coroutine function. The function must have the signature:
* @code void function(basic_yield_context<Handler> yield); @endcode
*
* @param attributes Boost.Coroutine attributes used to customise the coroutine.
*/
template <typename Handler, typename Function>
void spawn(BOOST_ASIO_MOVE_ARG(Handler) handler,
BOOST_ASIO_MOVE_ARG(Function) function,
const pdalboost::coroutines::attributes& attributes
= pdalboost::coroutines::attributes());
/// Start a new stackful coroutine, inheriting the execution context of another.
/**
* This function is used to launch a new coroutine.
*
* @param ctx Identifies the current coroutine as a parent of the new
* coroutine. This specifies that the new coroutine should inherit the
* execution context of the parent. For example, if the parent coroutine is
* executing in a particular strand, then the new coroutine will execute in the
* same strand.
*
* @param function The coroutine function. The function must have the signature:
示例9: BOOST_ASIO_INITFN_RESULT_TYPE
* @li Constructs an object @c result of type <tt>async_result<Handler></tt>,
* initializing the object as <tt>result(handler)</tt>.
*
* @li Obtains the handler's associated executor object @c ex by performing
* <tt>get_associated_executor(handler)</tt>.
*
* @li Obtains the handler's associated allocator object @c alloc by performing
* <tt>get_associated_allocator(handler)</tt>.
*
* @li Performs <tt>ex.dispatch(std::move(handler), alloc)</tt>.
*
* @li Returns <tt>result.get()</tt>.
*/
template <typename CompletionToken>
BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) dispatch(
BOOST_ASIO_MOVE_ARG(CompletionToken) token);
/// Submits a completion token or function object for execution.
/**
* This function submits an object for execution using the specified executor.
* The function object is queued for execution, and is never called from the
* current thread prior to returning from <tt>dispatch()</tt>.
*
* This function has the following effects:
*
* @li Constructs a function object handler of type @c Handler, initialized
* with <tt>handler(forward<CompletionToken>(token))</tt>.
*
* @li Constructs an object @c result of type <tt>async_result<Handler></tt>,
* initializing the object as <tt>result(handler)</tt>.
*
示例10: operator
template <typename CompletionHandler>
void operator()(BOOST_ASIO_MOVE_ARG(CompletionHandler) handler) const
{
typedef typename decay<CompletionHandler>::type DecayedHandler;
typename associated_executor<DecayedHandler>::type ex(
(get_associated_executor)(handler));
typename associated_allocator<DecayedHandler>::type alloc(
(get_associated_allocator)(handler));
ex.dispatch(BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler), alloc);
}
template <typename CompletionHandler, typename Executor>
void operator()(BOOST_ASIO_MOVE_ARG(CompletionHandler) handler,
BOOST_ASIO_MOVE_ARG(Executor) ex) const
{
typedef typename decay<CompletionHandler>::type DecayedHandler;
typename associated_allocator<DecayedHandler>::type alloc(
(get_associated_allocator)(handler));
ex.dispatch(detail::work_dispatcher<DecayedHandler>(
BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler)), alloc);
}
};
} // namespace detail
template <typename CompletionToken>
示例11: BOOST_ASIO_MOVE_ARG
#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/system_context.hpp>
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
inline system_context& system_executor::context() const BOOST_ASIO_NOEXCEPT
{
return detail::global<system_context>();
}
template <typename Function, typename Allocator>
void system_executor::dispatch(
BOOST_ASIO_MOVE_ARG(Function) f, const Allocator&) const
{
typename decay<Function>::type tmp(BOOST_ASIO_MOVE_CAST(Function)(f));
boost_asio_handler_invoke_helpers::invoke(tmp, tmp);
}
template <typename Function, typename Allocator>
void system_executor::post(
BOOST_ASIO_MOVE_ARG(Function) f, const Allocator& a) const
{
typedef typename decay<Function>::type function_type;
system_context& ctx = detail::global<system_context>();
// Allocate and construct an operation to wrap the function.
typedef detail::executor_op<function_type, Allocator> op;
示例12: BOOST_ASIO_DEFINE_HANDLER_ALLOCATOR_PTR
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
namespace detail {
template <typename Handler, typename Alloc,
typename Operation = scheduler_operation>
class executor_op : public Operation
{
public:
BOOST_ASIO_DEFINE_HANDLER_ALLOCATOR_PTR(executor_op);
template <typename H>
executor_op(BOOST_ASIO_MOVE_ARG(H) h, const Alloc& allocator)
: Operation(&executor_op::do_complete),
handler_(BOOST_ASIO_MOVE_CAST(H)(h)),
allocator_(allocator)
{
}
static void do_complete(void* owner, Operation* base,
const boost::system::error_code& /*ec*/,
std::size_t /*bytes_transferred*/)
{
// Take ownership of the handler object.
executor_op* o(static_cast<executor_op*>(base));
Alloc allocator(o->allocator_);
ptr p = { detail::addressof(allocator), o, o };
示例13: BOOST_ASIO_INITFN_RESULT_TYPE
* }
* }
*
* ...
*
* boost::asio::posix::stream_descriptor descriptor(io_context);
* ...
* descriptor.async_wait(
* boost::asio::posix::stream_descriptor::wait_read,
* wait_handler);
* @endcode
*/
template <typename WaitHandler>
BOOST_ASIO_INITFN_RESULT_TYPE(WaitHandler,
void (boost::system::error_code))
async_wait(wait_type w, BOOST_ASIO_MOVE_ARG(WaitHandler) handler)
{
// If you get an error on the following line it means that your handler does
// not meet the documented type requirements for a WaitHandler.
BOOST_ASIO_WAIT_HANDLER_CHECK(WaitHandler, handler) type_check;
async_completion<WaitHandler,
void (boost::system::error_code)> init(handler);
this->get_service().async_wait(
this->get_implementation(), w, init.completion_handler);
return init.result.get();
}
protected:
示例14: async_accept
* {
* // Accept succeeded.
* }
* }
*
* ...
*
* boost::asio::ip::tcp::acceptor acceptor(io_service);
* ...
* boost::asio::ip::tcp::socket socket(io_service);
* acceptor.async_accept(socket, accept_handler);
* @endcode
*/
template <typename SocketService, typename AcceptHandler>
void async_accept(basic_socket<protocol_type, SocketService>& peer,
BOOST_ASIO_MOVE_ARG(AcceptHandler) handler)
{
// If you get an error on the following line it means that your handler does
// not meet the documented type requirements for a AcceptHandler.
BOOST_ASIO_ACCEPT_HANDLER_CHECK(AcceptHandler, handler) type_check;
this->get_service().async_accept(this->get_implementation(),
peer, 0, BOOST_ASIO_MOVE_CAST(AcceptHandler)(handler));
}
/// Accept a new connection and obtain the endpoint of the peer
/**
* This function is used to accept a new connection from a peer into the
* given socket, and additionally provide the endpoint of the remote peer.
* The function call will block until a new connection has been accepted
* successfully or an error occurs.
示例15: basic_registration
: public basic_io_object<RegistrationService>
{
public:
explicit basic_registration(io_service& io,
std::string name)
// eventually, this will have to be wstring or
// something - name is UTF-8 [dns-sd.h : 883]
: basic_io_object<RegistrationService>(io)
{
}
/// Commit a registration
template <typename CommitHandler>
inline BOOST_ASIO_INITFN_RESULT_TYPE(CommitHandler,
void(boost::system::error_code))
async_commit(BOOST_ASIO_MOVE_ARG(CommitHandler) handler)
{
return this->get_service().async_commit(
this->get_implementation(),
BOOST_ASIO_MOVE_CAST(CommitHandler)(handler));
}
};
typedef basic_registration<registration_service> registration;
} // namespace dnssd
} // namespace ip
} // namespace asio
} // namespace boost