PIThreadPoolExecutor & PIBlockingDequeue improvements

- add support move & copy semantic
- introduce submit method for executor with future result
This commit is contained in:
8 changed files with 193 additions and 83 deletions

View File

@@ -3,12 +3,12 @@
#include "pithread.h"
#include "testutil.h"
class Mutex : public ::testing::Test, public TestUtil {
class MutexIntegartionTest : public ::testing::Test, public TestUtil {
public:
PIMutex* m = new PIMutex();
};
TEST_F(Mutex, lock_is_protect) {
TEST_F(MutexIntegartionTest, lock_is_protect) {
m->lock();
bool* isProtect = new bool(true);
@@ -20,7 +20,7 @@ TEST_F(Mutex, lock_is_protect) {
ASSERT_TRUE(*isProtect);
}
TEST_F(Mutex, unlock_is_release) {
TEST_F(MutexIntegartionTest, unlock_is_release) {
m->lock();
bool* isReleased = new bool(false);
m->unlock();
@@ -33,7 +33,7 @@ TEST_F(Mutex, unlock_is_release) {
ASSERT_TRUE(*isReleased);
}
TEST_F(Mutex, tryLock_is_false_when_locked) {
TEST_F(MutexIntegartionTest, tryLock_is_false_when_locked) {
createThread([&](){
m->lock();
piMSleep(WAIT_THREAD_TIME_MS);
@@ -41,11 +41,11 @@ TEST_F(Mutex, tryLock_is_false_when_locked) {
ASSERT_FALSE(m->tryLock());
}
TEST_F(Mutex, tryLock_is_true_when_unlocked) {
TEST_F(MutexIntegartionTest, tryLock_is_true_when_unlocked) {
ASSERT_TRUE(m->tryLock());
}
TEST_F(Mutex, tryLock_is_recursive_lock_enable) {
TEST_F(MutexIntegartionTest, tryLock_is_recursive_lock_enable) {
m->lock();
ASSERT_TRUE(m->tryLock());
}