From baeb371d355ea769c4cdbeb9fb82a2664643a3b3 Mon Sep 17 00:00:00 2001 From: nebula-bots <88429921+nebula-bots@users.noreply.github.com> Date: Fri, 18 Feb 2022 15:55:44 +0800 Subject: [PATCH] remove concurrent base/stringvalue, use boost::barrier instead (#3848) (#605) * remove concurrent stringvalue * delete cmakesetting.json * clang format code * revert format arg... * objectpool format * boost thread linkage * revert install-gcc.sh Co-authored-by: yuehua.jia <3423893+jiayuehua@users.noreply.github.com> --- src/common/CMakeLists.txt | 3 +- src/common/base/CMakeLists.txt | 1 - src/common/base/ObjectPool.h | 3 +- src/common/base/StringValue.cpp | 10 -- src/common/base/StringValue.h | 34 ------- src/common/concurrent/Barrier.cpp | 38 ------- src/common/concurrent/Barrier.h | 52 ---------- src/common/concurrent/CMakeLists.txt | 11 --- src/common/concurrent/Latch.cpp | 52 ---------- src/common/concurrent/Latch.h | 63 ------------ src/common/concurrent/test/BarrierTest.cpp | 93 ----------------- src/common/concurrent/test/CMakeLists.txt | 17 ---- src/common/concurrent/test/LatchTest.cpp | 110 --------------------- src/common/cpp/helpers.h | 18 ++-- src/common/thread/GenericThreadPool.h | 5 +- src/common/thread/GenericWorker.h | 4 +- src/common/thread/test/CMakeLists.txt | 1 - src/daemons/CMakeLists.txt | 2 - src/graph/executor/Executor.h | 3 +- src/graph/executor/test/CMakeLists.txt | 1 - src/graph/optimizer/OptContext.h | 3 +- src/graph/optimizer/test/CMakeLists.txt | 1 - src/graph/planner/test/CMakeLists.txt | 1 - src/graph/scheduler/Scheduler.h | 4 +- src/graph/service/QueryEngine.h | 4 +- src/graph/service/QueryInstance.h | 4 +- src/graph/service/RequestContext.h | 3 +- src/graph/util/test/CMakeLists.txt | 11 ++- src/graph/util/test/IdGeneratorTest.cpp | 6 +- src/kvstore/LogEncoder.h | 3 +- src/meta/processors/job/JobManager.h | 2 +- src/storage/GraphStorageLocalServer.h | 4 +- src/webservice/Router.h | 4 +- 33 files changed, 51 insertions(+), 520 deletions(-) delete mode 100644 src/common/base/StringValue.cpp delete mode 100644 src/common/base/StringValue.h delete mode 100644 src/common/concurrent/Barrier.cpp delete mode 100644 src/common/concurrent/Barrier.h delete mode 100644 src/common/concurrent/CMakeLists.txt delete mode 100644 src/common/concurrent/Latch.cpp delete mode 100644 src/common/concurrent/Latch.h delete mode 100644 src/common/concurrent/test/BarrierTest.cpp delete mode 100644 src/common/concurrent/test/CMakeLists.txt delete mode 100644 src/common/concurrent/test/LatchTest.cpp diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index daf780342ff..8d658930847 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -7,8 +7,6 @@ nebula_add_subdirectory(time) nebula_add_subdirectory(network) nebula_add_subdirectory(thrift) nebula_add_subdirectory(fs) -nebula_add_subdirectory(concurrent) -nebula_add_subdirectory(encryption) nebula_add_subdirectory(thread) nebula_add_subdirectory(process) nebula_add_subdirectory(hdfs) @@ -16,6 +14,7 @@ nebula_add_subdirectory(http) nebula_add_subdirectory(stats) nebula_add_subdirectory(charset) nebula_add_subdirectory(algorithm) +nebula_add_subdirectory(encryption) nebula_add_subdirectory(datatypes) nebula_add_subdirectory(conf) nebula_add_subdirectory(meta) diff --git a/src/common/base/CMakeLists.txt b/src/common/base/CMakeLists.txt index 802517822a3..22db6d19c43 100644 --- a/src/common/base/CMakeLists.txt +++ b/src/common/base/CMakeLists.txt @@ -14,7 +14,6 @@ nebula_add_library( SanitizerOptions.cpp SignalHandler.cpp SlowOpTracker.cpp - StringValue.cpp ${gdb_debug_script} ) diff --git a/src/common/base/ObjectPool.h b/src/common/base/ObjectPool.h index 7f73e5a2c60..04235f4bc88 100644 --- a/src/common/base/ObjectPool.h +++ b/src/common/base/ObjectPool.h @@ -8,6 +8,7 @@ #include +#include #include #include #include @@ -21,7 +22,7 @@ class Expression; typedef std::lock_guard SLGuard; -class ObjectPool final : private cpp::NonCopyable, private cpp::NonMovable { +class ObjectPool final : private boost::noncopyable, private cpp::NonMovable { public: ObjectPool() {} diff --git a/src/common/base/StringValue.cpp b/src/common/base/StringValue.cpp deleted file mode 100644 index a31b96582d7..00000000000 --- a/src/common/base/StringValue.cpp +++ /dev/null @@ -1,10 +0,0 @@ -/* Copyright (c) 2019 vesoft inc. All rights reserved. - * - * This source code is licensed under Apache 2.0 License. - */ - -#include "common/base/StringValue.h" - -#include "common/base/Base.h" - -namespace nebula {} // namespace nebula diff --git a/src/common/base/StringValue.h b/src/common/base/StringValue.h deleted file mode 100644 index 3ae23a352ce..00000000000 --- a/src/common/base/StringValue.h +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright (c) 2019 vesoft inc. All rights reserved. - * - * This source code is licensed under Apache 2.0 License. - */ - -#ifndef COMMON_BASE_STRINGVALUE_H_ -#define COMMON_BASE_STRINGVALUE_H_ - -#include "common/base/Base.h" - -namespace nebula { - -/** - * This class is a wrapper of the std::string. It provides operations - * between std::string and other value types - */ -class StringValue final { - public: - explicit StringValue(std::string str) : str_(std::move(str)) {} - - const std::string& str() const& { - return str_; - } - - std::string&& str() && { - return std::move(str_); - } - - private: - std::string str_; -}; - -} // namespace nebula -#endif // COMMON_BASE_STRINGVALUE_H_ diff --git a/src/common/concurrent/Barrier.cpp b/src/common/concurrent/Barrier.cpp deleted file mode 100644 index 27cf64f625d..00000000000 --- a/src/common/concurrent/Barrier.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (c) 2018 vesoft inc. All rights reserved. - * - * This source code is licensed under Apache 2.0 License. - */ - -#include "common/concurrent/Barrier.h" - -#include "common/base/Base.h" - -namespace nebula { -namespace concurrent { - -Barrier::Barrier(size_t counter, std::function completion) { - if (counter == 0) { - throw std::invalid_argument("Barrier counter can't be zero"); - } - completion_ = std::move(completion); - counter_ = counter; - ages_ = counter_; -} - -void Barrier::wait() { - std::unique_lock guard(lock_); - if (--ages_ == 0) { - ages_ = counter_; - ++generation_; - if (completion_ != nullptr) { - completion_(); - } - cond_.notify_all(); - } else { - auto current = generation_; - cond_.wait(guard, [=]() { return current != generation_; }); - } -} - -} // namespace concurrent -} // namespace nebula diff --git a/src/common/concurrent/Barrier.h b/src/common/concurrent/Barrier.h deleted file mode 100644 index 91fabb7ea99..00000000000 --- a/src/common/concurrent/Barrier.h +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (c) 2018 vesoft inc. All rights reserved. - * - * This source code is licensed under Apache 2.0 License. - */ -#ifndef COMMON_CONCURRENT_BARRIER_H_ -#define COMMON_CONCURRENT_BARRIER_H_ - -#include "common/base/Base.h" -#include "common/cpp/helpers.h" - -/** - * Like `Latch', `Barrier' is a synchronization object, except that - * `Barrier' is reusable. - * Besides, `Barrier' features with an optional callable object, - * which would be invoked at the completion phase, i.e. synchronization point, - * by the last participating thread who entered `wait', before waking up other - * blocking threads. - */ - -namespace nebula { -namespace concurrent { - -class Barrier final : public nebula::cpp::NonCopyable, public nebula::cpp::NonMovable { - public: - /** - * @counter number of participating threads - * @completion callback invoked at the completion phase - */ - explicit Barrier(size_t counter, std::function completion = nullptr); - ~Barrier() = default; - /** - * Decrements the internal counter. - * If the counter reaches zero, the completion callback would be invoked if - * present, then all preceding blocked threads would be woken up, with the - * internal counter reset to the original value. Otherwise, the calling thread - * would be blocked to wait for other participants' arrival. - */ - void wait(); - - private: - std::function completion_{nullptr}; - size_t counter_{0}; - size_t ages_{0}; - size_t generation_{0}; - std::mutex lock_; - std::condition_variable cond_; -}; - -} // namespace concurrent -} // namespace nebula - -#endif // COMMON_CONCURRENT_BARRIER_H_ diff --git a/src/common/concurrent/CMakeLists.txt b/src/common/concurrent/CMakeLists.txt deleted file mode 100644 index 3b7e899e7cd..00000000000 --- a/src/common/concurrent/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright (c) 2020 vesoft inc. All rights reserved. -# -# This source code is licensed under Apache 2.0 License. - -nebula_add_library( - concurrent_obj OBJECT - Barrier.cpp - Latch.cpp -) - -nebula_add_subdirectory(test) diff --git a/src/common/concurrent/Latch.cpp b/src/common/concurrent/Latch.cpp deleted file mode 100644 index 57e99ed96ed..00000000000 --- a/src/common/concurrent/Latch.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (c) 2018 vesoft inc. All rights reserved. - * - * This source code is licensed under Apache 2.0 License. - */ - -#include "common/concurrent/Latch.h" - -#include "common/base/Base.h" - -namespace nebula { -namespace concurrent { - -Latch::Latch(size_t counter) { - if (counter == 0) { - throw std::invalid_argument("Zero Latch counter"); - } - counter_ = counter; -} - -void Latch::down() { - std::unique_lock unique(lock_); - if (counter_ == 0) { - throw std::runtime_error("Count down on zero Latch"); - } - if (--counter_ == 0) { - cond_.notify_all(); - } -} - -void Latch::downWait() { - std::unique_lock unique(lock_); - if (counter_ == 0) { - throw std::runtime_error("Count down on zero Latch"); - } - if (--counter_ == 0) { - cond_.notify_all(); - return; - } - cond_.wait(unique, [this]() { return counter_ == 0; }); -} - -void Latch::wait() { - std::unique_lock unique(lock_); - cond_.wait(unique, [this]() { return counter_ == 0; }); -} - -bool Latch::isReady() { - return counter_ == 0; -} - -} // namespace concurrent -} // namespace nebula diff --git a/src/common/concurrent/Latch.h b/src/common/concurrent/Latch.h deleted file mode 100644 index a112064ebb4..00000000000 --- a/src/common/concurrent/Latch.h +++ /dev/null @@ -1,63 +0,0 @@ -/* Copyright (c) 2018 vesoft inc. All rights reserved. - * - * This source code is licensed under Apache 2.0 License. - */ -#ifndef COMMON_CONCURRENT_LATCH_H_ -#define COMMON_CONCURRENT_LATCH_H_ - -#include "common/base/Base.h" -#include "common/cpp/helpers.h" -/** - * Latch is an one-shot synchronization object. - * It provides an synchronization point for multiple threads. - * See shared/concurrent/test/LatchTest.cpp for use scenarios. - */ - -namespace nebula { -namespace concurrent { - -class Latch final : public nebula::cpp::NonCopyable, public nebula::cpp::NonMovable { - public: - /** - * @counter: initial counter, - * typically number of participating threads. - * Throws `std::invalid_argument' if counter is zero. - */ - explicit Latch(size_t counter); - ~Latch() = default; - /** - * Decrements the internal counter by one. - * If the counter reaches 0, all blocking(in `wait') - * threads will be given the green light. - * Throws `std::runtime_error' if counter already zeroed. - */ - void down(); - /** - * Decrements the internal counter by one. - * If the counter reaches 0, returns immediately, - * and all blocking threads will be woken up. - * Otherwise, the calling thread blocks until being woken up. - * Throws `std::runtime_error' if counter already zeroed. - */ - void downWait(); - /** - * Blocks if internal counter not zero. - * Otherwise, returns immediately. - */ - void wait(); - /** - * Returns true if internal counter already zeroed. - * Otherwise, returns false. - */ - bool isReady(); - - private: - volatile size_t counter_{0}; - std::mutex lock_; - std::condition_variable cond_; -}; - -} // namespace concurrent -} // namespace nebula - -#endif // COMMON_CONCURRENT_LATCH_H_ diff --git a/src/common/concurrent/test/BarrierTest.cpp b/src/common/concurrent/test/BarrierTest.cpp deleted file mode 100644 index 98bdc4d3f87..00000000000 --- a/src/common/concurrent/test/BarrierTest.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* Copyright (c) 2018 vesoft inc. All rights reserved. - * - * This source code is licensed under Apache 2.0 License. - */ -#include - -#include "common/base/Base.h" -#include "common/concurrent/Barrier.h" -#include "common/thread/GenericThreadPool.h" - -namespace nebula { -namespace concurrent { - -TEST(BarrierTest, BasicTest) { - // test for invalid initial counter - { - ASSERT_THROW({ Barrier barrier(0UL); }, std::invalid_argument); - } - // test for single-thread normal case - { - Barrier barrier(1UL); - barrier.wait(); - ASSERT_TRUE(true); - } - // test for multiple-thread normal case - { - Barrier barrier(2UL); - std::atomic counter{0}; - auto cb = [&]() { - barrier.wait(); - ++counter; - }; - std::thread thread(cb); - usleep(1000); - ASSERT_EQ(0UL, counter.load()); - barrier.wait(); - thread.join(); - ASSERT_EQ(1UL, counter.load()); - } - // test for multiple-thread completion - { - std::atomic counter{0}; - auto completion = [&]() { - ++counter; - ++counter; - }; - Barrier barrier(2UL, completion); - - auto cb = [&]() { - barrier.wait(); - ++counter; - }; - - std::thread thread(cb); - usleep(1000); - ASSERT_EQ(0UL, counter.load()); - barrier.wait(); - ASSERT_GE(counter.load(), 2UL); - thread.join(); - ASSERT_EQ(3UL, counter.load()); - } -} - -TEST(BarrierTest, ConsecutiveTest) { - std::atomic counter{0}; - constexpr auto N = 64UL; - constexpr auto iters = 100UL; - auto completion = [&]() { - // At the completion phase, `counter' should be multiple to `N'. - ASSERT_EQ(0UL, counter.load() % N); - }; - - Barrier barrier(N, completion); - auto cb = [&]() { - auto i = iters; - while (i-- != 0) { - ++counter; - barrier.wait(); - } - }; - - std::vector threads; - for (auto i = 0UL; i < N; i++) { - threads.emplace_back(cb); - } - for (auto &thread : threads) { - thread.join(); - } - ASSERT_EQ(0UL, counter.load() % N); -} - -} // namespace concurrent -} // namespace nebula diff --git a/src/common/concurrent/test/CMakeLists.txt b/src/common/concurrent/test/CMakeLists.txt deleted file mode 100644 index db1ff55fdec..00000000000 --- a/src/common/concurrent/test/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright (c) 2020 vesoft inc. All rights reserved. -# -# This source code is licensed under Apache 2.0 License. - -nebula_add_test( - NAME - concurrent_test - SOURCES - BarrierTest.cpp LatchTest.cpp - OBJECTS - $ - $ - $ - LIBRARIES - gtest - gtest_main -) diff --git a/src/common/concurrent/test/LatchTest.cpp b/src/common/concurrent/test/LatchTest.cpp deleted file mode 100644 index e586bc92000..00000000000 --- a/src/common/concurrent/test/LatchTest.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/* Copyright (c) 2018 vesoft inc. All rights reserved. - * - * This source code is licensed under Apache 2.0 License. - */ - -#include - -#include "common/base/Base.h" -#include "common/concurrent/Latch.h" -#include "common/thread/GenericThreadPool.h" - -namespace nebula { -namespace concurrent { - -TEST(LatchTest, BasicTest) { - // test for invalid initial counter - { - ASSERT_THROW({ Latch latch(0); }, std::invalid_argument); - } - // test for illegal `downWait' - { - ASSERT_THROW( - { - Latch latch(1); - latch.down(); - latch.downWait(); - }, - std::runtime_error); - } - // test for illegal `down' - { - ASSERT_THROW( - { - Latch latch(1); - latch.down(); - latch.down(); - }, - std::runtime_error); - } - // test for single-thread normal case - { - Latch latch(1); - ASSERT_FALSE(latch.isReady()); - latch.down(); - ASSERT_TRUE(latch.isReady()); - latch.wait(); - latch.wait(); - ASSERT_TRUE(true); - } - // test for multiple-thread normal case - { - Latch latch(2); - auto cb = [&]() { latch.downWait(); }; - std::thread thread(cb); - ASSERT_FALSE(latch.isReady()); - latch.downWait(); - ASSERT_TRUE(latch.isReady()); - thread.join(); - } -} - -TEST(LatchTest, JoinLikeTest) { - // start bunch of tasks, then wait for them all done. - constexpr auto nthreads = 4UL; - constexpr auto ntasks = 16UL; - thread::GenericThreadPool pool; - Latch latch(ntasks); - std::atomic counter{0}; - auto task = [&]() { - ++counter; - latch.down(); - }; - pool.start(nthreads); - for (auto i = 0UL; i < ntasks; i++) { - pool.addTask(task); - } - latch.wait(); - ASSERT_EQ(ntasks, counter.load()); -} - -TEST(LatchTest, SignalTest) { - // There are preceding I/O works and subsequent CPU bound works. - // Do I/O works with single thread, and CPU works concurrently. - constexpr auto nthreads = 16UL; - constexpr auto ntasks = 16UL; - thread::GenericThreadPool pool; - Latch latch(1); - pool.start(nthreads); - std::atomic counter{0}; - auto task = [&]() { - // do some preparing works - latch.wait(); // wait for the I/O works done - // do subsequent CPU bound works, where parallelism is more efficient. - ++counter; - }; - for (auto i = 0UL; i < ntasks; i++) { - pool.addTask(task); - } - // sleep to simulate I/O bound task, which single threading suffices - usleep(100000); - // I/O works done - ASSERT_EQ(0, counter.load()); // no CPU bound work done. - latch.down(); - pool.stop(); - pool.wait(); // wait all tasks done - ASSERT_EQ(ntasks, counter.load()); // all tasks are done -} - -} // namespace concurrent -} // namespace nebula diff --git a/src/common/cpp/helpers.h b/src/common/cpp/helpers.h index b73fc518432..8ae3b05cd59 100644 --- a/src/common/cpp/helpers.h +++ b/src/common/cpp/helpers.h @@ -8,24 +8,18 @@ namespace nebula { namespace cpp { -class NonCopyable { - protected: - NonCopyable() {} - NonCopyable(const NonCopyable&) = delete; - NonCopyable& operator=(const NonCopyable&) = delete; -}; +class NonMovable { + public: + NonMovable() = default; + ~NonMovable() = default; -static_assert(sizeof(NonCopyable) == 1UL, "Unexpected sizeof(NonCopyable)!"); + NonMovable(const NonMovable&) = default; + NonMovable& operator=(const NonMovable&) = default; -class NonMovable { - protected: - NonMovable() {} NonMovable(NonMovable&&) = delete; NonMovable& operator=(NonMovable&&) = delete; }; -static_assert(sizeof(NonMovable) == 1UL, "Unexpected sizeof(NonMovable)!"); - } // namespace cpp } // namespace nebula #endif // COMMON_CPP_HELPERS_H_ diff --git a/src/common/thread/GenericThreadPool.h b/src/common/thread/GenericThreadPool.h index fc2bdd87ccf..5f30aa207a1 100644 --- a/src/common/thread/GenericThreadPool.h +++ b/src/common/thread/GenericThreadPool.h @@ -5,6 +5,9 @@ #ifndef COMMON_THREAD_GENERICTHREADPOOL_H_ #define COMMON_THREAD_GENERICTHREADPOOL_H_ +#include + +#include "common/cpp/helpers.h" #include "common/thread/GenericWorker.h" /** @@ -21,7 +24,7 @@ namespace nebula { namespace thread { -class GenericThreadPool final : public nebula::cpp::NonCopyable, public nebula::cpp::NonMovable { +class GenericThreadPool final : public boost::noncopyable, public nebula::cpp::NonMovable { public: GenericThreadPool(); ~GenericThreadPool(); diff --git a/src/common/thread/GenericWorker.h b/src/common/thread/GenericWorker.h index 80999197b12..d29254b090e 100644 --- a/src/common/thread/GenericWorker.h +++ b/src/common/thread/GenericWorker.h @@ -8,6 +8,8 @@ #include #include +#include + #include "common/base/Base.h" #include "common/cpp/helpers.h" #include "common/thread/NamedThread.h" @@ -31,7 +33,7 @@ struct event_base; namespace nebula { namespace thread { -class GenericWorker final : public nebula::cpp::NonCopyable, public nebula::cpp::NonMovable { +class GenericWorker final : public boost::noncopyable, public nebula::cpp::NonMovable { public: friend class GenericThreadPool; diff --git a/src/common/thread/test/CMakeLists.txt b/src/common/thread/test/CMakeLists.txt index 8189e21cad3..dea12ffff56 100644 --- a/src/common/thread/test/CMakeLists.txt +++ b/src/common/thread/test/CMakeLists.txt @@ -11,7 +11,6 @@ nebula_add_test( GenericThreadPoolTest.cpp OBJECTS $ - $ $ LIBRARIES gtest diff --git a/src/daemons/CMakeLists.txt b/src/daemons/CMakeLists.txt index 15f91515ee2..1a729fda07a 100644 --- a/src/daemons/CMakeLists.txt +++ b/src/daemons/CMakeLists.txt @@ -144,7 +144,6 @@ nebula_add_executable( $ $ $ - $ $ $ $ @@ -270,7 +269,6 @@ nebula_add_executable( $ $ $ - $ $ $ $ diff --git a/src/graph/executor/Executor.h b/src/graph/executor/Executor.h index 0ed54b3c7c0..bb9a1ffb595 100644 --- a/src/graph/executor/Executor.h +++ b/src/graph/executor/Executor.h @@ -8,6 +8,7 @@ #include +#include #include #include #include @@ -25,7 +26,7 @@ namespace graph { class PlanNode; class QueryContext; -class Executor : private cpp::NonCopyable, private cpp::NonMovable { +class Executor : private boost::noncopyable, private cpp::NonMovable { public: // Create executor according to plan node static Executor *create(const PlanNode *node, QueryContext *qctx); diff --git a/src/graph/executor/test/CMakeLists.txt b/src/graph/executor/test/CMakeLists.txt index 06f3840dd41..01b6572b7d5 100644 --- a/src/graph/executor/test/CMakeLists.txt +++ b/src/graph/executor/test/CMakeLists.txt @@ -22,7 +22,6 @@ SET(EXEC_QUERY_TEST_OBJS $ $ $ - $ $ $ $ diff --git a/src/graph/optimizer/OptContext.h b/src/graph/optimizer/OptContext.h index 6f6b32d6da3..20da572b8a3 100644 --- a/src/graph/optimizer/OptContext.h +++ b/src/graph/optimizer/OptContext.h @@ -6,6 +6,7 @@ #ifndef GRAPH_OPTIMIZER_OPTCONTEXT_H_ #define GRAPH_OPTIMIZER_OPTCONTEXT_H_ +#include #include #include @@ -23,7 +24,7 @@ namespace opt { class OptGroupNode; -class OptContext final : private cpp::NonCopyable, private cpp::NonMovable { +class OptContext final : private boost::noncopyable, private cpp::NonMovable { public: explicit OptContext(graph::QueryContext *qctx); diff --git a/src/graph/optimizer/test/CMakeLists.txt b/src/graph/optimizer/test/CMakeLists.txt index e5d7224bd0d..daf4d0a95af 100644 --- a/src/graph/optimizer/test/CMakeLists.txt +++ b/src/graph/optimizer/test/CMakeLists.txt @@ -5,7 +5,6 @@ set(OPTIMIZER_TEST_LIB $ - $ $ $ $ diff --git a/src/graph/planner/test/CMakeLists.txt b/src/graph/planner/test/CMakeLists.txt index 908bf28eae3..b721fd684b0 100644 --- a/src/graph/planner/test/CMakeLists.txt +++ b/src/graph/planner/test/CMakeLists.txt @@ -43,7 +43,6 @@ nebula_add_test( $ $ $ - $ $ $ $ diff --git a/src/graph/scheduler/Scheduler.h b/src/graph/scheduler/Scheduler.h index 3a4bc97722f..c05f7ddcdd1 100644 --- a/src/graph/scheduler/Scheduler.h +++ b/src/graph/scheduler/Scheduler.h @@ -6,6 +6,8 @@ #ifndef GRAPH_SCHEDULER_SCHEDULER_H_ #define GRAPH_SCHEDULER_SCHEDULER_H_ +#include + #include "common/base/Base.h" #include "common/base/Status.h" #include "graph/executor/Executor.h" @@ -13,7 +15,7 @@ namespace nebula { namespace graph { -class Scheduler : private cpp::NonCopyable, private cpp::NonMovable { +class Scheduler : private boost::noncopyable, private cpp::NonMovable { public: Scheduler() = default; virtual ~Scheduler() = default; diff --git a/src/graph/service/QueryEngine.h b/src/graph/service/QueryEngine.h index 0e90e9b5950..5d16e9971aa 100644 --- a/src/graph/service/QueryEngine.h +++ b/src/graph/service/QueryEngine.h @@ -8,6 +8,8 @@ #include +#include + #include "clients/meta/MetaClient.h" #include "clients/storage/StorageClient.h" #include "common/charset/Charset.h" @@ -27,7 +29,7 @@ namespace graph { * For the time being, we don't have the execution plan cache support, * instead we create a plan for each query, and destroy it upon finish. */ -class QueryEngine final : public cpp::NonCopyable, public cpp::NonMovable { +class QueryEngine final : public boost::noncopyable, public cpp::NonMovable { public: QueryEngine() = default; ~QueryEngine() = default; diff --git a/src/graph/service/QueryInstance.h b/src/graph/service/QueryInstance.h index a7b8ccc489c..a30168d56cc 100644 --- a/src/graph/service/QueryInstance.h +++ b/src/graph/service/QueryInstance.h @@ -6,6 +6,8 @@ #ifndef GRAPH_SERVICE_QUERYINSTANCE_H_ #define GRAPH_SERVICE_QUERYINSTANCE_H_ +#include + #include "common/base/Status.h" #include "common/cpp/helpers.h" #include "graph/context/QueryContext.h" @@ -22,7 +24,7 @@ namespace nebula { namespace graph { -class QueryInstance final : public cpp::NonCopyable, public cpp::NonMovable { +class QueryInstance final : public boost::noncopyable, public cpp::NonMovable { public: explicit QueryInstance(std::unique_ptr qctx, opt::Optimizer* optimizer); ~QueryInstance() = default; diff --git a/src/graph/service/RequestContext.h b/src/graph/service/RequestContext.h index 0114ab4307c..ca0eb571ae7 100644 --- a/src/graph/service/RequestContext.h +++ b/src/graph/service/RequestContext.h @@ -5,6 +5,7 @@ #ifndef GRAPH_REQUESTCONTEXT_H_ #define GRAPH_REQUESTCONTEXT_H_ +#include #include "audit/AuditLogging.h" #include "common/base/Base.h" @@ -28,7 +29,7 @@ namespace nebula { namespace graph { template -class RequestContext final : public cpp::NonCopyable, public cpp::NonMovable { +class RequestContext final : public boost::noncopyable, public cpp::NonMovable { public: RequestContext() = default; ~RequestContext() { diff --git a/src/graph/util/test/CMakeLists.txt b/src/graph/util/test/CMakeLists.txt index 1ce32e0c9f2..1538299c745 100644 --- a/src/graph/util/test/CMakeLists.txt +++ b/src/graph/util/test/CMakeLists.txt @@ -8,6 +8,15 @@ set(UTIL_TEST_FLAG_DEPS $ ) endif() +find_library(Boost_Thread_LIBRARY NAMES libboost_thread.a) + +if(Boost_Thread_LIBRARY) + mark_as_advanced( + Boost_Thread_LIBRARY + ) +else() + message(FATAL_ERROR "boost_thread doesn't exist") +endif() nebula_add_test( NAME utils_test @@ -16,7 +25,6 @@ nebula_add_test( IdGeneratorTest.cpp OBJECTS $ - $ $ $ $ @@ -63,6 +71,7 @@ nebula_add_test( LIBRARIES gtest gtest_main + ${Boost_Thread_LIBRARY} ${THRIFT_LIBRARIES} ${PROXYGEN_LIBRARIES} ${Ldap_LIBRARIES} diff --git a/src/graph/util/test/IdGeneratorTest.cpp b/src/graph/util/test/IdGeneratorTest.cpp index a36897387c2..b784b6e19c4 100644 --- a/src/graph/util/test/IdGeneratorTest.cpp +++ b/src/graph/util/test/IdGeneratorTest.cpp @@ -2,11 +2,11 @@ * * This source code is licensed under Apache 2.0 License. */ - #include +#include + #include "common/base/Base.h" -#include "common/concurrent/Barrier.h" #include "graph/util/IdGenerator.h" namespace nebula { @@ -14,7 +14,7 @@ namespace graph { TEST(IdGeneratorTest, gen) { // Use the current id as the start id const int64_t curId = EPIdGenerator::instance().id() + 1; - nebula::concurrent::Barrier bar(3); + boost::barrier bar(3); std::vector ids1; auto t1 = std::thread([&ids1, &bar, &curId]() { for (auto i = 0; i < 5; ++i) { diff --git a/src/kvstore/LogEncoder.h b/src/kvstore/LogEncoder.h index 11bac4305eb..4e8b024472b 100644 --- a/src/kvstore/LogEncoder.h +++ b/src/kvstore/LogEncoder.h @@ -5,6 +5,7 @@ #ifndef KVSTORE_LOGENCODER_H_ #define KVSTORE_LOGENCODER_H_ +#include #include "common/cpp/helpers.h" #include "kvstore/Common.h" @@ -144,7 +145,7 @@ int64_t getTimestamp(const folly::StringPiece& log); /** * @brief A wrapper class of batchs of log, support put/remove/removeRange */ -class BatchHolder : public nebula::cpp::NonCopyable, public nebula::cpp::NonMovable { +class BatchHolder : public boost::noncopyable, public nebula::cpp::NonMovable { public: BatchHolder() = default; ~BatchHolder() = default; diff --git a/src/meta/processors/job/JobManager.h b/src/meta/processors/job/JobManager.h index ad741b052b9..0d23e85204b 100644 --- a/src/meta/processors/job/JobManager.h +++ b/src/meta/processors/job/JobManager.h @@ -26,7 +26,7 @@ namespace nebula { namespace meta { extern stats::CounterId kNumRunningJobs; -class JobManager : public nebula::cpp::NonCopyable, public nebula::cpp::NonMovable { +class JobManager : public boost::noncopyable, public nebula::cpp::NonMovable { friend class JobManagerTest; friend class GetStatsTest; FRIEND_TEST(JobManagerTest, reserveJobId); diff --git a/src/storage/GraphStorageLocalServer.h b/src/storage/GraphStorageLocalServer.h index 7c726e9af86..39d93929058 100644 --- a/src/storage/GraphStorageLocalServer.h +++ b/src/storage/GraphStorageLocalServer.h @@ -9,6 +9,7 @@ #include #include +#include #include #include "common/base/Base.h" @@ -16,8 +17,7 @@ #include "folly/fibers/Semaphore.h" #include "interface/gen-cpp2/GraphStorageServiceAsyncClient.h" namespace nebula::storage { -class GraphStorageLocalServer final : public nebula::cpp::NonCopyable, - public nebula::cpp::NonMovable { +class GraphStorageLocalServer final : public boost::noncopyable, public nebula::cpp::NonMovable { public: static std::shared_ptr getInstance() { static std::shared_ptr instance{new GraphStorageLocalServer()}; diff --git a/src/webservice/Router.h b/src/webservice/Router.h index dcf112b2d8a..237acf57170 100644 --- a/src/webservice/Router.h +++ b/src/webservice/Router.h @@ -5,9 +5,9 @@ #ifndef WEBSERVICE_ROUTER_H_ #define WEBSERVICE_ROUTER_H_ - #include +#include #include #include #include @@ -67,7 +67,7 @@ class Route final { std::vector groups_; }; -class Router final : public cpp::NonCopyable, public cpp::NonMovable { +class Router final : public boost::noncopyable, public cpp::NonMovable { public: explicit Router(const std::string &prefix) : prefix_(prefix), webSvc_(nullptr) {} Router(const std::string &prefix, const WebService *webSvc)