Boost Asio总结(4) io_service
生活随笔
收集整理的這篇文章主要介紹了
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