Remove remainder of PIP and use library instruction
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#include "gtest/gtest.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "testutil.h"
|
||||
#include "piblockingdequeue.h"
|
||||
#include "blockingdequeue.h"
|
||||
|
||||
using ::testing::_;
|
||||
using ::testing::Return;
|
||||
@@ -77,15 +77,15 @@ public:
|
||||
template<typename T>
|
||||
class MockDeque: public NiceMock<MockDequeBase<T>> {};
|
||||
|
||||
class PIBlockingDequeuePrepare: public PIBlockingDequeue<QueueElement, MockDeque, NiceMock<MockConditionVar>> {
|
||||
class BlockingDequeuePrepare: public BlockingDequeue<QueueElement, MockDeque, NiceMock<MockConditionVar>> {
|
||||
public:
|
||||
typedef PIBlockingDequeue<QueueElement, MockDeque, NiceMock<MockConditionVar>> SuperClass;
|
||||
typedef BlockingDequeue<QueueElement, MockDeque, NiceMock<MockConditionVar>> SuperClass;
|
||||
|
||||
explicit PIBlockingDequeuePrepare(size_t capacity = SIZE_MAX): SuperClass(capacity) { }
|
||||
explicit BlockingDequeuePrepare(size_t capacity = SIZE_MAX): SuperClass(capacity) { }
|
||||
|
||||
template<typename Iterable,
|
||||
typename std::enable_if<!std::is_arithmetic<Iterable>::value, int>::type = 0>
|
||||
explicit PIBlockingDequeuePrepare(const Iterable& other): SuperClass(other) { }
|
||||
explicit BlockingDequeuePrepare(const Iterable& other): SuperClass(other) { }
|
||||
|
||||
MockConditionVar* getCondVarAdd() { return this->cond_var_add; }
|
||||
MockConditionVar* getCondVarRem() { return this->cond_var_rem; }
|
||||
@@ -97,7 +97,7 @@ class BlockingDequeueUnitTest: public ::testing::Test {
|
||||
public:
|
||||
int timeout = 100;
|
||||
size_t capacity;
|
||||
PIBlockingDequeuePrepare dequeue;
|
||||
BlockingDequeuePrepare dequeue;
|
||||
QueueElement element;
|
||||
|
||||
BlockingDequeueUnitTest(): capacity(1), dequeue(capacity), element(11) {}
|
||||
@@ -108,12 +108,12 @@ public:
|
||||
};
|
||||
|
||||
TEST_F(BlockingDequeueUnitTest, construct_default_is_max_size_eq_size_max) {
|
||||
PIBlockingDequeuePrepare dequeue;
|
||||
BlockingDequeuePrepare dequeue;
|
||||
ASSERT_EQ(dequeue.getMaxSize(), SIZE_MAX);
|
||||
}
|
||||
|
||||
TEST_F(BlockingDequeueUnitTest, construct_from_constant_is_max_size_eq_capacity) {
|
||||
PIBlockingDequeuePrepare dequeue(2);
|
||||
BlockingDequeuePrepare dequeue(2);
|
||||
ASSERT_EQ(dequeue.getMaxSize(), 2);
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ TEST_F(BlockingDequeueUnitTest, construct_from_iterable) {
|
||||
std::vector<QueueElement> iterable;
|
||||
iterable.emplace_back(11);
|
||||
iterable.emplace_back(22);
|
||||
PIBlockingDequeuePrepare dequeue(iterable);
|
||||
BlockingDequeuePrepare dequeue(iterable);
|
||||
}
|
||||
|
||||
void BlockingDequeueUnitTest::put_is_wait_predicate(bool isCapacityReach) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "gtest/gtest.h"
|
||||
#include "testutil.h"
|
||||
#include "piexecutor.h"
|
||||
#include "executor.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace chrono;
|
||||
@@ -8,7 +8,7 @@ using namespace chrono;
|
||||
TEST(ExcutorIntegrationTest, execute_is_runnable_invoke) {
|
||||
std::mutex m;
|
||||
int invokedRunnables = 0;
|
||||
PIThreadPoolExecutor executorService(1);
|
||||
ThreadPoolExecutor executorService(1);
|
||||
executorService.execute([&]() {
|
||||
m.lock();
|
||||
invokedRunnables++;
|
||||
@@ -22,7 +22,7 @@ TEST(ExcutorIntegrationTest, execute_is_runnable_invoke) {
|
||||
|
||||
TEST(ExcutorIntegrationTest, execute_is_not_execute_after_shutdown) {
|
||||
volatile bool isRunnableInvoke = false;
|
||||
PIThreadPoolExecutor executorService(1);
|
||||
ThreadPoolExecutor executorService(1);
|
||||
executorService.shutdown();
|
||||
executorService.execute([&]() {
|
||||
isRunnableInvoke = true;
|
||||
@@ -33,7 +33,7 @@ TEST(ExcutorIntegrationTest, execute_is_not_execute_after_shutdown) {
|
||||
|
||||
TEST(ExcutorIntegrationTest, execute_is_execute_before_shutdown) {
|
||||
volatile bool isRunnableInvoke = false;
|
||||
PIThreadPoolExecutor executorService(1);
|
||||
ThreadPoolExecutor executorService(1);
|
||||
executorService.execute([&]() {
|
||||
this_thread::sleep_for(milliseconds(WAIT_THREAD_TIME_MS));
|
||||
isRunnableInvoke = true;
|
||||
@@ -45,7 +45,7 @@ TEST(ExcutorIntegrationTest, execute_is_execute_before_shutdown) {
|
||||
|
||||
// FIXME
|
||||
TEST(DISABLED_ExcutorIntegrationTest, execute_is_awaitTermination_wait) {
|
||||
PIThreadPoolExecutor executorService(1);
|
||||
ThreadPoolExecutor executorService(1);
|
||||
executorService.execute([&]() {
|
||||
this_thread::sleep_for(milliseconds(2 * WAIT_THREAD_TIME_MS));
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "gtest/gtest.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "testutil.h"
|
||||
#include "piexecutor.h"
|
||||
#include "executor.h"
|
||||
|
||||
using ::testing::_;
|
||||
using ::testing::SetArgReferee;
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
MOCK_METHOD0(join, void());
|
||||
};
|
||||
|
||||
class MockDeque : public PIBlockingDequeue<FunctionWrapper> {
|
||||
class MockDeque : public BlockingDequeue<FunctionWrapper> {
|
||||
public:
|
||||
MOCK_METHOD1(offer, bool(const FunctionWrapper&));
|
||||
MOCK_METHOD0(take, FunctionWrapper());
|
||||
@@ -49,14 +49,14 @@ public:
|
||||
MOCK_METHOD0(remainingCapacity, size_t());
|
||||
};
|
||||
|
||||
typedef PIThreadPoolExecutorTemplate<NiceMock<MockThread>, MockDeque> PIThreadPoolExecutorMoc_t;
|
||||
typedef ThreadPoolExecutorTemplate<NiceMock<MockThread>, MockDeque> ThreadPoolExecutorMoc_t;
|
||||
|
||||
class PIThreadPoolExecutorMoc : public PIThreadPoolExecutorMoc_t {
|
||||
class ThreadPoolExecutorMoc : public ThreadPoolExecutorMoc_t {
|
||||
public:
|
||||
explicit PIThreadPoolExecutorMoc(size_t corePoolSize) : PIThreadPoolExecutorMoc_t(corePoolSize) { }
|
||||
explicit ThreadPoolExecutorMoc(size_t corePoolSize) : ThreadPoolExecutorMoc_t(corePoolSize) { }
|
||||
|
||||
template<typename Function>
|
||||
explicit PIThreadPoolExecutorMoc(size_t corePoolSize, Function onBeforeStart) : PIThreadPoolExecutorMoc_t(corePoolSize, onBeforeStart) { }
|
||||
explicit ThreadPoolExecutorMoc(size_t corePoolSize, Function onBeforeStart) : ThreadPoolExecutorMoc_t(corePoolSize, onBeforeStart) { }
|
||||
|
||||
std::vector<testing::NiceMock<MockThread>*>* getThreadPool() { return &threadPool; }
|
||||
bool isShutdown() { return thread_command_ != thread_command::run; }
|
||||
@@ -64,18 +64,18 @@ public:
|
||||
};
|
||||
|
||||
TEST(ExecutorUnitTest, is_corePool_created) {
|
||||
PIThreadPoolExecutorMoc executor(THREAD_COUNT);
|
||||
ThreadPoolExecutorMoc executor(THREAD_COUNT);
|
||||
ASSERT_EQ(THREAD_COUNT, executor.getThreadPool()->size());
|
||||
}
|
||||
|
||||
TEST(ExecutorUnitTest, is_corePool_started) {
|
||||
PIThreadPoolExecutorMoc executor(THREAD_COUNT);
|
||||
ThreadPoolExecutorMoc executor(THREAD_COUNT);
|
||||
for (auto* thread : *executor.getThreadPool()) ASSERT_TRUE(thread->is_executed);
|
||||
}
|
||||
|
||||
TEST(ExecutorUnitTest, submit_is_added_to_taskQueue) {
|
||||
VoidFunc voidFunc = [](){};
|
||||
PIThreadPoolExecutorMoc executor(THREAD_COUNT);
|
||||
ThreadPoolExecutorMoc executor(THREAD_COUNT);
|
||||
// TODO add check of offered
|
||||
EXPECT_CALL(*executor.getTaskQueue(), offer)
|
||||
.WillOnce(Return(true));
|
||||
@@ -84,7 +84,7 @@ TEST(ExecutorUnitTest, submit_is_added_to_taskQueue) {
|
||||
|
||||
TEST(ExecutorUnitTest, submit_is_return_valid_future) {
|
||||
VoidFunc voidFunc = [](){};
|
||||
PIThreadPoolExecutorMoc executor(THREAD_COUNT);
|
||||
ThreadPoolExecutorMoc executor(THREAD_COUNT);
|
||||
// TODO add check of offered
|
||||
EXPECT_CALL(*executor.getTaskQueue(), offer)
|
||||
.WillOnce(Return(true));
|
||||
@@ -94,7 +94,7 @@ TEST(ExecutorUnitTest, submit_is_return_valid_future) {
|
||||
|
||||
TEST(ExecutorUnitTest, execute_is_added_to_taskQueue) {
|
||||
VoidFunc voidFunc = [](){};
|
||||
PIThreadPoolExecutorMoc executor(THREAD_COUNT);
|
||||
ThreadPoolExecutorMoc executor(THREAD_COUNT);
|
||||
// TODO add check of offered
|
||||
EXPECT_CALL(*executor.getTaskQueue(), offer)
|
||||
.WillOnce(Return(true));
|
||||
@@ -104,7 +104,7 @@ TEST(ExecutorUnitTest, execute_is_added_to_taskQueue) {
|
||||
// TODO fix
|
||||
TEST(DISABLED_ExecutorUnitTest, is_corePool_execute_queue_elements) {
|
||||
bool is_executed = false;
|
||||
PIThreadPoolExecutorMoc executor(1);
|
||||
ThreadPoolExecutorMoc executor(1);
|
||||
EXPECT_EQ(executor.getThreadPool()->size(), 1);
|
||||
EXPECT_CALL(*executor.getTaskQueue(), poll(Ge(0)))
|
||||
.WillOnce([&is_executed](int){
|
||||
@@ -117,7 +117,7 @@ TEST(DISABLED_ExecutorUnitTest, is_corePool_execute_queue_elements) {
|
||||
// FIXME
|
||||
TEST(DISABLED_ExecutorUnitTest, shutdown_is_stop_threads) {
|
||||
// Exclude stop calls when executor deleting
|
||||
auto* executor = new PIThreadPoolExecutorMoc(THREAD_COUNT, [](MockThread* thread){
|
||||
auto* executor = new ThreadPoolExecutorMoc(THREAD_COUNT, [](MockThread* thread){
|
||||
testing::Mock::AllowLeak(thread);
|
||||
EXPECT_CALL(*thread, join())
|
||||
.WillOnce(Return());
|
||||
|
||||
Reference in New Issue
Block a user