各位大佬,我的問題時這樣的:
有一個類為A,希望在執行其Start函式時注冊一個定時器,定時檢測該類成員變數內容,這個類可能會實體化多個實體,目前用的代碼是:
timer = boost::asio::deadline_timer(io_timer, boost::posix_time::seconds(60));
timer.async_wait(boost::bind(&Server::timer_tick, this));
boost::thread thread_timer(boost::bind(&boost::asio::io_service::run, &io_timer));
//thread_timer.join();
//io_timer.run();
//定時器設定完成
&Server::timer_tick為回呼函式,A類的成員函式
io_timer.run();的執行會導致后續代碼無法執行,請問如何做到定時器和其他代碼并行執行呢?
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/42947.html
標籤:應用程序開發區
