- 论坛徽章:
- 9
|
本帖最后由 wlmqgzm 于 2015-10-19 12:00 编辑
我的地址池, 测试代码, 也是高可靠性设计, 不会丢失一个任务包.
主程序退出后, 后台会继续完成已经提交的任务.
Log: Time=2015-10-19T11:38:43.670560, Line=54, File="/cpp/mysql1/asio_thread_pool.hpp", Func="Asio_thread_pool", Msg="Asio_thread_pool start for ios_public thread_count=2"
Log: Time=2015-10-19T11:38:43.670621, Line=159, File="/cpp/mysql1/asio_thread_pool.hpp", Func="test_asio_thread_pool", Msg="test main thread game over."
0.000012s wall, 0.000000s user + 0.000000s system = 0.000000s CPU (n/a%) //注意这里: 主进程已经退出, 调用了boost::timer::auto_cpu_timer 的析构函数
Log: Time=2015-10-19T11:38:43.870671, Line=123, File="/cpp/mysql1/asio_thread_pool.hpp", Func="calc_sum", Msg="run3 begin. "
Log: Time=2015-10-19T11:38:43.870685, Line=123, File="/cpp/mysql1/asio_thread_pool.hpp", Func="calc_sum", Msg="run1 begin. "
Log: Time=2015-10-19T11:38:43.870787, Line=130, File="/cpp/mysql1/asio_thread_pool.hpp", Func="calc_sum", Msg="run1 end. sum=5000050000"
Log: Time=2015-10-19T11:38:43.870817, Line=123, File="/cpp/mysql1/asio_thread_pool.hpp", Func="calc_sum", Msg="run4 begin. "
Log: Time=2015-10-19T11:38:43.870696, Line=123, File="/cpp/mysql1/asio_thread_pool.hpp", Func="calc_sum", Msg="run2 begin. "
Log: Time=2015-10-19T11:38:43.880792, Line=130, File="/cpp/mysql1/asio_thread_pool.hpp", Func="calc_sum", Msg="run4 end. sum=50000005000000"
Log: Time=2015-10-19T11:38:43.881228, Line=123, File="/cpp/mysql1/asio_thread_pool.hpp", Func="calc_sum", Msg="run6 begin. "
Log: Time=2015-10-19T11:38:43.881268, Line=130, File="/cpp/mysql1/asio_thread_pool.hpp", Func="calc_sum", Msg="run6 end. sum=5000050000"
Log: Time=2015-10-19T11:38:43.881275, Line=123, File="/cpp/mysql1/asio_thread_pool.hpp", Func="calc_sum", Msg="run7 begin. "
Log: Time=2015-10-19T11:38:43.885651, Line=130, File="/cpp/mysql1/asio_thread_pool.hpp", Func="calc_sum", Msg="run7 end. sum=50000005000000"
Log: Time=2015-10-19T11:38:43.888127, Line=123, File="/cpp/mysql1/asio_thread_pool.hpp", Func="calc_sum", Msg="run8 begin. "
Log: Time=2015-10-19T11:38:43.888171, Line=130, File="/cpp/mysql1/asio_thread_pool.hpp", Func="calc_sum", Msg="run8 end. sum=500500"
Log: Time=2015-10-19T11:38:43.888305, Line=123, File="/cpp/mysql1/asio_thread_pool.hpp", Func="calc_sum", Msg="run9 begin. "
Log: Time=2015-10-19T11:38:43.888595, Line=130, File="/cpp/mysql1/asio_thread_pool.hpp", Func="calc_sum", Msg="run9 end. sum=500000500000"
Log: Time=2015-10-19T11:38:43.905807, Line=130, File="/cpp/mysql1/asio_thread_pool.hpp", Func="calc_sum", Msg="run3 end. sum=5000000050000000"
Log: Time=2015-10-19T11:38:43.905874, Line=123, File="/cpp/mysql1/asio_thread_pool.hpp", Func="calc_sum", Msg="run5 begin. "
Log: Time=2015-10-19T11:38:43.944729, Line=130, File="/cpp/mysql1/asio_thread_pool.hpp", Func="calc_sum", Msg="run5 end. sum=5000000050000000"
Log: Time=2015-10-19T11:38:43.944760, Line=123, File="/cpp/mysql1/asio_thread_pool.hpp", Func="calc_sum", Msg="run10 begin. "
Log: Time=2015-10-19T11:38:43.944767, Line=130, File="/cpp/mysql1/asio_thread_pool.hpp", Func="calc_sum", Msg="run10 end. sum=55"
Log: Time=2015-10-19T11:38:44.186242, Line=130, File="/cpp/mysql1/asio_thread_pool.hpp", Func="calc_sum", Msg="run2 end. sum=500000000500000000"
Log: Time=2015-10-19T11:38:44.186328, Line=63, File="/cpp/mysql1/asio_thread_pool.hpp", Func="~Asio_thread_pool", Msg="~Asio_thread_pool()."
guo@guo-desktop:/cpp/mysql1/bin/Release$
// 注意主进程退出前后: 上下2个时间有200毫秒的间隔, 这个也是高可靠性设计的体现, 防止调用的主线程还没有彻底初始化完毕,或者正在初始化, 出现各种奇怪的无法定位的问题,
// 后面线程库启动时, 未来即使有超大对象, 主线程的各变量经过200毫秒的等待, 应该都初始化完成, 可以安全的使用了, 呵呵呵呵.
// 高可靠性设计 无处不在, 细节决定成败
|
|