当前位置:
首页 >
Boost Asio总结(4) io_service
发布时间:2025/3/21
34
豆豆
生活随笔
收集整理的这篇文章主要介绍了
Boost Asio总结(4) io_service
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
io_service类代表了系统里的异步处理机制(如epoll),必须在asio库里的其他对象之前初始化,其他对象则向io_service提交异步操作handler。
typedef io_context io_service;class io_context: public execution_context { private:typedef detail::io_context_impl impl_type; #if defined(BOOST_ASIO_HAS_IOCP)friend class detail::win_iocp_overlapped_ptr; #endifpublic:class executor_type;friend class executor_type;#if !defined(BOOST_ASIO_NO_DEPRECATED)class work; //有work在进行friend class work; //内部的线程类 #endif // !defined(BOOST_ASIO_NO_DEPRECATED)class service;#if !defined(BOOST_ASIO_NO_EXTENSIONS)class strand; #endif // !defined(BOOST_ASIO_NO_EXTENSIONS)BOOST_ASIO_DECL count_type run(); //阻塞执行事件循环BOOST_ASIO_DECL count_type run_one();//至少阻塞执行一个handlerBOOST_ASIO_DECL count_type poll();//非阻塞,执行ready的handlerBOOST_ASIO_DECL count_type poll_one();//至少执行一个ready的handlerBOOST_ASIO_DECL void stop();//停止事件循环BOOST_ASIO_DECL bool stopped() const;//事件循环是否已经停止void reset();//重启事件循环//异步执行一个handlertemplate <typename LegacyCompletionHandler>BOOST_ASIO_INITFN_RESULT_TYPE(LegacyCompletionHandler, void ())dispatch(BOOST_ASIO_MOVE_ARG(LegacyCompletionHandler) handler);//异步执行一个handlertemplate <typename LegacyCompletionHandler>BOOST_ASIO_INITFN_RESULT_TYPE(LegacyCompletionHandler, void ())post(BOOST_ASIO_MOVE_ARG(LegacyCompletionHandler) handler);总结
以上是生活随笔为你收集整理的Boost Asio总结(4) io_service的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: Boost Asio总结(3)异步通信
- 下一篇: Boost Asio总结(5)class