Fixed tests and improve multithread sync
This commit is contained in:
@@ -160,7 +160,7 @@ TEST_F(ConditionVariable, DISABLED_waitFor_is_block_before_timeout) {
|
||||
}
|
||||
|
||||
TEST_F(ConditionVariable, waitFor_is_unblock_when_timeout) {
|
||||
volatile bool isUnblock = false;
|
||||
std::atomic_bool isUnblock(false);
|
||||
createThread([&](){
|
||||
m.lock();
|
||||
variable->waitFor(m, WAIT_THREAD_TIME_MS);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define AWRCANFLASHER_TESTUTIL_H
|
||||
|
||||
#include "pithread.h"
|
||||
#include <atomic>
|
||||
|
||||
/**
|
||||
* Minimum wait thread start, switch context or another interthread communication action time. Increase it if tests
|
||||
@@ -16,10 +17,12 @@ PIOBJECT(TestUtil)
|
||||
public:
|
||||
double threadStartTime;
|
||||
PIThread* thread = new PIThread();
|
||||
volatile bool isRunning = false;
|
||||
std::atomic_bool isRunning;
|
||||
std::function<void()> adapterFunctionDefault;
|
||||
|
||||
bool createThread(const std::function<void()>& fun = nullptr, PIThread* thread_ = nullptr) {
|
||||
TestUtil() : isRunning(false) {}
|
||||
|
||||
bool createThread(const std::function<void()>& fun = nullptr, PIThread* thread_ = nullptr) {
|
||||
std::function<void()> actualFun = fun == nullptr ? adapterFunctionDefault : fun;
|
||||
if (thread_ == nullptr) thread_ = thread;
|
||||
thread_->startOnce([=](void*){
|
||||
|
||||
Reference in New Issue
Block a user