int main() { signal(SIGINT,[](int ){ Logger::Destory(); exit(0); }); //初始化日志系统 Logger::Instance().add(std::make_shared<ConsoleChannel> ("stdout", LTrace)); atomic_llong count(0); ThreadPool pool(1,ThreadPool::PRIORITY_HIGHEST, false); Ticker ticker; for (int i = 0 ; i < 1000*10000;++i){ pool.async([&](){ if(++count >= 1000*10000){ InfoL << "总共耗时:" << ticker.elapsedTime() << "," << count; } }); } InfoL << "ThreadPool::async耗时:" << ticker.elapsedTime() << endl; uint64_t lastCount = 0 ,nowCount = 0; ticker.resetTime(); //此处才开始启动线程 pool.start(); while (true){ sleep(1); nowCount = count.load(); InfoL << nowCount - lastCount; lastCount = nowCount; } return 0; }