void threadPool_unittest()
{
threadPool pool("MainThreadPool");
pool.setMaxQueueSize(1);
pool.start(5);
pool.run(print);
pool.run(print);
for (int i = 0; i < 1000; ++i)
{
char buf[32];
snprintf(buf, sizeof buf, "task %d", i);
pool.run(std::bind(printString, std::string(buf)));
}
//这里是添加一个结束的符号,调用下面三条语句才是真正结束
muduo::CountDownLatch latch(1);
pool.run(std::bind(&muduo::CountDownLatch::countDown, &latch));
latch.wait();
pool.stop();
}