refactor concurrent module code

This commit is contained in:
3 changed files with 58 additions and 35 deletions

View File

@@ -71,10 +71,6 @@ TEST(ExecutorUnitTest, is_corePool_started) {
.WillOnce(Return(true));
});
EXPECT_EQ(THREAD_COUNT, executor.getThreadPool()->size());
executor.getThreadPool()->forEach([](MockThread* thread){
EXPECT_CALL(*thread, stop())
.WillOnce(Return());
});
}
TEST(ExecutorUnitTest, execute_is_added_to_taskQueue) {
@@ -94,9 +90,19 @@ TEST(ExecutorUnitTest, is_corePool_execute_queue_elements) {
executor.getThreadPool()->at(0)->runnnable();
ASSERT_TRUE(is_executed);
}
/* FIXME
TEST(ExecutorUnitTest, shutdown_is_stop_threads) {
PIThreadPoolExecutorMoc executor(THREAD_COUNT);
executor.shutdown();
// Exclude stop calls when executor deleting
auto* executor = new PIThreadPoolExecutorMoc(THREAD_COUNT, [](MockThread* thread){
testing::Mock::AllowLeak(thread);
EXPECT_CALL(*thread, stop())
.WillOnce(Return());
});
testing::Mock::AllowLeak(executor);
testing::Mock::AllowLeak(executor->getTaskQueue());
EXPECT_CALL(*executor->getTaskQueue(), poll(Ge(0)))
.WillRepeatedly(Return(std::function<VoidFunc()>()));
executor->shutdown();
executor->getThreadPool()->forEach([](MockThread* thread){ thread->runnnable(); });
}
*/