fix race condition in CallAfterTimeoutTest

This commit is contained in:
Sebastian Messmer 2018-02-02 12:34:45 -08:00
parent f040c8ca54
commit 400a5b5397

View File

@ -1,6 +1,7 @@
#include <gtest/gtest.h>
#include <cpp-utils/pointer/unique_ref.h>
#include <cryfs-cli/CallAfterTimeout.h>
#include <atomic>
using cpputils::unique_ref;
using cpputils::make_unique_ref;
@ -11,11 +12,13 @@ using namespace cryfs;
class CallAfterTimeoutTest : public ::testing::Test {
public:
CallAfterTimeoutTest(): called(false) {}
unique_ref<CallAfterTimeout> callAfterTimeout(milliseconds timeout) {
return make_unique_ref<CallAfterTimeout>(timeout, [this] {called = true;});
}
bool called = false;
std::atomic<bool> called;
};
TEST_F(CallAfterTimeoutTest, NoReset_1) {