merged concurrent to main library
removed PIConditionLock, use PIMutex instead
This commit is contained in:
@@ -8,24 +8,24 @@ public:
|
||||
bool isTrueCondition = false;
|
||||
int timeout = -1;
|
||||
|
||||
void wait(PIConditionLock& lk) override {
|
||||
void wait(PIMutex& lk) override {
|
||||
isWaitCalled = true;
|
||||
}
|
||||
|
||||
void wait(PIConditionLock& lk, const std::function<bool()>& condition) override {
|
||||
void wait(PIMutex& lk, const std::function<bool()>& condition) override {
|
||||
isWaitCalled = true;
|
||||
lk.lock();
|
||||
isTrueCondition = condition();
|
||||
lk.unlock();
|
||||
}
|
||||
|
||||
bool waitFor(PIConditionLock& lk, int timeoutMs) override {
|
||||
bool waitFor(PIMutex& lk, int timeoutMs) override {
|
||||
isWaitForCalled = true;
|
||||
timeout = timeoutMs;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool waitFor(PIConditionLock& lk, int timeoutMs, const std::function<bool()>& condition) override {
|
||||
bool waitFor(PIMutex& lk, int timeoutMs, const std::function<bool()>& condition) override {
|
||||
isWaitForCalled = true;
|
||||
lk.lock();
|
||||
isTrueCondition = condition();
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
#include "piconditionvar.h"
|
||||
#include <pithread.h>
|
||||
#include "pithread.h"
|
||||
#include "testutil.h"
|
||||
|
||||
class ConditionLock : public ::testing::Test, public TestUtil {
|
||||
public:
|
||||
PIConditionLock* m = new PIConditionLock();
|
||||
PIMutex* m = new PIMutex();
|
||||
};
|
||||
|
||||
TEST_F(ConditionLock, lock_is_protect) {
|
||||
@@ -50,4 +50,4 @@ TEST_F(ConditionLock, tryLock_is_true_when_unlocked) {
|
||||
TEST_F(ConditionLock, tryLock_is_recursive_lock_enable) {
|
||||
m->lock();
|
||||
ASSERT_TRUE(m->tryLock());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
class ConditionVariable : public ::testing::Test, public TestUtil {
|
||||
public:
|
||||
PIConditionLock m;
|
||||
PIMutex m;
|
||||
PIConditionVariable* variable;
|
||||
|
||||
protected:
|
||||
@@ -197,4 +197,4 @@ TEST_F(ConditionVariable, waitFor_is_unblock_when_condition_and_notifyOne) {
|
||||
variable->notifyOne();
|
||||
msleep(WAIT_THREAD_TIME_MS);
|
||||
ASSERT_FALSE(thread->isRunning());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "gtest/gtest.h"
|
||||
#include "executor.h"
|
||||
#include "pithreadpoolexecutor.h"
|
||||
#include "pimutex.h"
|
||||
|
||||
const int WAIT_THREAD_TIME_MS = 30;
|
||||
@@ -51,4 +51,4 @@ TEST(ExcutorIntegrationTest, execute_is_awaitTermination_wait) {
|
||||
double waitTime = measurer.elapsed_m();
|
||||
ASSERT_GE(waitTime, WAIT_THREAD_TIME_MS);
|
||||
ASSERT_LE(waitTime, 4 * WAIT_THREAD_TIME_MS);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user