• <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影院| 久久久久久久久66精品片| 97久久精品人人澡人人爽| 久久99精品久久久久久水蜜桃| 国产香蕉久久精品综合网| 久久天天躁狠狠躁夜夜96流白浆| 久久91精品久久91综合| 99久久精品免费看国产| 久久精品成人欧美大片| 国产精品成人久久久久三级午夜电影| 久久久亚洲裙底偷窥综合| 国产福利电影一区二区三区久久老子无码午夜伦不| 国产精品狼人久久久久影院| 国产毛片欧美毛片久久久| 久久久久无码精品| 久久综合久久久| 久久综合给合久久狠狠狠97色| 久久伊人亚洲AV无码网站| 国产精品久久99| www性久久久com| 欧美黑人激情性久久| 一本久久精品一区二区| 精品人妻伦一二三区久久| 狠狠色噜噜狠狠狠狠狠色综合久久| 中文字幕无码久久久| 久久久网中文字幕| 99久久精品国产综合一区| 国产精品久久久久无码av| 久久久免费精品re6| 久久亚洲私人国产精品| 久久亚洲日韩看片无码| 伊人色综合久久天天人守人婷 | 99久久伊人精品综合观看| 蜜臀av性久久久久蜜臀aⅴ| 无码国内精品久久人妻蜜桃| 亚洲日本va午夜中文字幕久久| 久久人人爽人人爽人人片AV麻豆| 精品久久久久久久久久久久久久久| 99久久精品这里只有精品| 国产精品嫩草影院久久| 91久久精品无码一区二区毛片|