1#include <atomic>
2#include <iostream>
3#include <Common/ThreadPool.h>
4
5#include <gtest/gtest.h>
6
7
8TEST(ThreadPool, Loop)
9{
10 std::atomic<int> res{0};
11
12 for (size_t i = 0; i < 1000; ++i)
13 {
14 size_t threads = 16;
15 ThreadPool pool(threads);
16 for (size_t j = 0; j < threads; ++j)
17 pool.scheduleOrThrowOnError([&] { ++res; });
18 pool.wait();
19 }
20
21 EXPECT_EQ(res, 16000);
22}
23