Files
Seele/tests/Engine/ThreadPool.cpp
T

20 lines
404 B
C++
Raw Normal View History

2023-12-18 08:37:25 +01:00
#include "EngineTest.h"
#include "ThreadPool.h"
#include <numeric>
TEST(ThreadPool, RunBatch)
{
ThreadPool t(10);
uint32 test = 20;
std::mutex m;
2023-12-18 13:03:03 +01:00
List<std::function<void()>> work;
2023-12-22 19:46:07 +01:00
for (uint32 i = 0; i < 40000; ++i)
2023-12-18 08:37:25 +01:00
{
2023-12-18 13:03:03 +01:00
work.add([&]() {
2023-12-18 08:37:25 +01:00
std::unique_lock l(m);
test++;
2023-12-18 13:03:03 +01:00
});
2023-12-18 08:37:25 +01:00
}
t.runAndWait(std::move(work));
2023-12-22 19:46:07 +01:00
ASSERT_EQ(test, 40020);
2023-12-18 08:37:25 +01:00
}