feat add thread_pool test case
Some checks failed
linux-mips64-gcc / linux-gcc-mips64el (Release) (push) Successful in 2m22s
linux-x64-gcc / linux-gcc (Debug) (push) Failing after 1m24s
linux-x64-gcc / linux-gcc (Release) (push) Failing after 1m21s
linux-mips64-gcc / linux-gcc-mips64el (Debug) (push) Successful in 4m3s
Some checks failed
linux-mips64-gcc / linux-gcc-mips64el (Release) (push) Successful in 2m22s
linux-x64-gcc / linux-gcc (Debug) (push) Failing after 1m24s
linux-x64-gcc / linux-gcc (Release) (push) Failing after 1m21s
linux-mips64-gcc / linux-gcc-mips64el (Debug) (push) Successful in 4m3s
This commit is contained in:
parent
a711d6bfb4
commit
9444c23db2
@ -1,4 +1,5 @@
|
||||
#include <random>
|
||||
#include <sled/synchronization/event.h>
|
||||
#include <sled/system/thread_pool.h>
|
||||
|
||||
std::random_device rd;
|
||||
@ -37,7 +38,9 @@ multiply_return(const int a, const int b)
|
||||
return res;
|
||||
}
|
||||
|
||||
TEST_CASE("ThreadPool")
|
||||
TEST_SUITE("ThreadPool")
|
||||
{
|
||||
TEST_CASE("submit")
|
||||
{
|
||||
sled::ThreadPool *tp = new sled::ThreadPool();
|
||||
REQUIRE_NE(tp, nullptr);
|
||||
@ -60,3 +63,22 @@ TEST_CASE("ThreadPool")
|
||||
|
||||
delete tp;
|
||||
}
|
||||
TEST_CASE("PostTask")
|
||||
{
|
||||
sled::ThreadPool *tp = new sled::ThreadPool();
|
||||
sled::Event waiter;
|
||||
tp->PostTask([&]() { waiter.Set(); });
|
||||
CHECK(waiter.Wait(sled::TimeDelta::Seconds(1)));
|
||||
delete tp;
|
||||
}
|
||||
|
||||
TEST_CASE("PostDelayedTask")
|
||||
{
|
||||
sled::ThreadPool *tp = new sled::ThreadPool();
|
||||
sled::Event waiter;
|
||||
tp->PostDelayedTask([&]() { waiter.Set(); }, sled::TimeDelta::Millis(100));
|
||||
CHECK_FALSE(waiter.Wait(sled::TimeDelta::Millis(50)));
|
||||
CHECK(waiter.Wait(sled::TimeDelta::Millis(150)));
|
||||
delete tp;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user