Fix thread worker unit test so it handles repeat runs (#2479)

This commit is contained in:
cryptocode 2020-01-14 14:13:46 +01:00 committed by GitHub
commit 5bb6542180
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -7,19 +7,15 @@
#include <boost/filesystem.hpp>
namespace
{
std::atomic<bool> passed_sleep{ false };
void func ()
{
std::this_thread::sleep_for (std::chrono::seconds (1));
passed_sleep = true;
}
}
TEST (thread, worker)
{
std::atomic<bool> passed_sleep{ false };
auto func = [&passed_sleep]() {
std::this_thread::sleep_for (std::chrono::seconds (1));
passed_sleep = true;
};
nano::worker worker;
worker.push_task (func);
ASSERT_FALSE (passed_sleep);