当前位置: 首页>>代码示例>>C++>>正文


C++ BOOST_ASIO_MOVE_ARG函数代码示例

本文整理汇总了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);

}}}
开发者ID:flavioroth,项目名称:boost-fiber,代码行数:49,代码来源:spawn.hpp

示例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));
    }
开发者ID:cboulay,项目名称:labstreaminglayer,代码行数:12,代码来源:basic_socket_acceptor.hpp

示例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();
  }
开发者ID:chrisaljoudi,项目名称:ssf,代码行数:50,代码来源:fiber_acceptor_service.hpp

示例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错误.
开发者ID:hicdre,项目名称:avhttp,代码行数:31,代码来源:http_stream.hpp

示例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();
开发者ID:Sandern,项目名称:py-source-sdk-2013,代码行数:31,代码来源:object_handle_service.hpp

示例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
开发者ID:3Jade,项目名称:Sprawl,代码行数:31,代码来源:read_at.hpp

示例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();
  }
开发者ID:BranchMetrics,项目名称:react-native-branch-deep-linking,代码行数:30,代码来源:stream.hpp

示例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:
开发者ID:GeospatialDaryl,项目名称:PDAL,代码行数:31,代码来源:spawn.hpp

示例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>.
 *
开发者ID:ASMlover,项目名称:study,代码行数:31,代码来源:dispatch.hpp

示例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>
开发者ID:boostorg,项目名称:asio,代码行数:31,代码来源:dispatch.hpp

示例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;
开发者ID:PopcornTimeTV,项目名称:PopcornTorrent,代码行数:31,代码来源:system_executor.hpp

示例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 };
开发者ID:PopcornTimeTV,项目名称:PopcornTorrent,代码行数:29,代码来源:executor_op.hpp

示例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:
开发者ID:CustomOrthopaedics,项目名称:OTS-Boost,代码行数:31,代码来源:descriptor.hpp

示例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.
开发者ID:AndresGalaviz,项目名称:NAO,代码行数:31,代码来源:basic_socket_acceptor.hpp

示例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
开发者ID:bkietz,项目名称:boost-asio-dnssd,代码行数:30,代码来源:registration.hpp


注:本文中的BOOST_ASIO_MOVE_ARG函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。