• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            Error

            C++博客 首頁 新隨筆 聯系 聚合 管理
              217 Posts :: 61 Stories :: 32 Comments :: 0 Trackbacks
            // learn_boost_asio.cpp : 定義控制臺應用程序的入口點。
            //
            #include "stdafx.h"
            #include <iostream>
            #include <algorithm>
            #include <memory>
            #include <boost/asio.hpp>
            #include <boost/timer.hpp>
            #include <boost/lambda/lambda.hpp>
            #include <boost/function.hpp>
            #include <boost/bind.hpp>
            namespace asio = boost::asio;
            namespace posix_time = boost::posix_time ;
            // 1.同步定時器使用
            void LeanrHowToUseSynchronouslyTimer()
            {
            asio::io_service io;
            asio::deadline_timer deadLineTimer(io, posix_time::seconds(3));
            boost::timer timerTestDeadLineTimer;
            timerTestDeadLineTimer.restart();
            deadLineTimer.wait();
            double dTime = timerTestDeadLineTimer.elapsed();
            std::cout << dTime << std::endl;
            }
            ////////~
            // 2.異步定時器使用
            class CSomeObject
            {
            public:
            CSomeObject(asio::io_service& ioService) :
               m_deadLineTimer(ioService)
            {
            }
            public:
            void Test()
            {
            m_deadLineTimer.expires_from_now(boost::posix_time::seconds(3));
            m_timerTestDeadTimer.restart();
            m_deadLineTimer.async_wait(
            boost::bind(&CSomeObject::TimerHandler, this, asio::placeholders::error));
            }
            public:
            void TimerHandler(const boost::system::error_code&)
            {
            double dTime = m_timerTestDeadTimer.elapsed();
            std::cout << "time passed: " << dTime << std::endl;
            }
            private:
            boost::timer m_timerTestDeadTimer;
            asio::deadline_timer m_deadLineTimer;
            };
            void LearnHowToUseAsynchronouslyTimer()
            {
            asio::io_service ioService;
            CSomeObject obj(ioService);
            obj.Test();
            asio::io_service::work* pWork = new asio::io_service::work(ioService);
            std::auto_ptr<asio::io_service::work> spWork(pWork);
            ioService.run();
            //spWork.reset(); // Allow run() to exit. 
            }
            //////////////////////////////////////////
            int _tmain(int argc, _TCHAR* argv[])
            {
            LearnHowToUseAsynchronouslyTimer();
            return 0;
            }
            posted on 2013-03-08 18:04 Enic 閱讀(790) 評論(0)  編輯 收藏 引用 所屬分類: boost::asio
            久久久久久亚洲精品成人| 久久精品国产亚洲AV电影| 国产精品久久久久久久久久影院 | 久久91精品国产91久久小草| 99久久综合狠狠综合久久止| 久久不见久久见免费影院www日本| 午夜精品久久久久成人| 久久AV高清无码| 久久精品国产精品亚洲| 欧美一区二区三区久久综合| 久久精品成人欧美大片| 久久99热只有频精品8| 亚洲精品无码久久久| 国内精品久久久久久99| 久久伊人五月天论坛| 久久夜色精品国产噜噜麻豆 | 7777久久亚洲中文字幕| 久久久久国产亚洲AV麻豆| 久久国产免费观看精品3| 中文精品99久久国产| 国产香蕉97碰碰久久人人| 婷婷综合久久中文字幕蜜桃三电影| 久久无码精品一区二区三区| 国产一久久香蕉国产线看观看| 国产成年无码久久久免费| 久久精品国产亚洲7777| 久久久中文字幕| 久久九九亚洲精品| 波多野结衣中文字幕久久| 亚洲国产视频久久| 中文国产成人精品久久亚洲精品AⅤ无码精品 | 久久99精品国产麻豆宅宅| 看久久久久久a级毛片| 久久精品国产免费观看| 国产69精品久久久久APP下载 | 国产精品一久久香蕉国产线看观看| 国产精品久久久久a影院| 综合久久给合久久狠狠狠97色| 久久se精品一区二区影院| 成人精品一区二区久久| 精品久久久久久无码中文字幕 |