From 0b4ce256de7a46365ab142341a213d42c659103a Mon Sep 17 00:00:00 2001 From: wbq_sky Date: Tue, 19 Oct 2021 21:21:05 +0800 Subject: [PATCH] fix the header conflict Signed-off-by: wbq_sky --- .../libs/distributeddb/BUILD.gn | 2 +- .../include/{semaphore.h => semaphore_utils.h} | 12 ++++++------ .../distributeddb/common/src/auto_launch.cpp | 4 ++-- .../src/{semaphore.cpp => semaphore_utils.cpp} | 18 +++++++++--------- .../communicator/include/frame_combiner.h | 4 ++-- .../syncer/include/sync_operation.h | 4 ++-- .../syncer/src/single_ver_sync_state_machine.h | 2 +- .../syncer/src/sync_operation.cpp | 2 +- .../syncer/src/sync_task_context.h | 2 +- .../libs/distributeddb/test/BUILD.gn | 4 ++-- 10 files changed, 27 insertions(+), 27 deletions(-) rename services/distributeddataservice/libs/distributeddb/common/include/{semaphore.h => semaphore_utils.h} (84%) rename services/distributeddataservice/libs/distributeddb/common/src/{semaphore.cpp => semaphore_utils.cpp} (73%) diff --git a/services/distributeddataservice/libs/distributeddb/BUILD.gn b/services/distributeddataservice/libs/distributeddb/BUILD.gn index 4eb85e939..6001241c0 100755 --- a/services/distributeddataservice/libs/distributeddb/BUILD.gn +++ b/services/distributeddataservice/libs/distributeddb/BUILD.gn @@ -82,7 +82,7 @@ ohos_shared_library("distributeddb") { "common/src/runtime_context_impl.cpp", "common/src/schema_object.cpp", "common/src/schema_utils.cpp", - "common/src/semaphore.cpp", + "common/src/semaphore_utils.cpp", "common/src/task_pool.cpp", "common/src/task_pool_impl.cpp", "common/src/task_queue.cpp", diff --git a/services/distributeddataservice/libs/distributeddb/common/include/semaphore.h b/services/distributeddataservice/libs/distributeddb/common/include/semaphore_utils.h similarity index 84% rename from services/distributeddataservice/libs/distributeddb/common/include/semaphore.h rename to services/distributeddataservice/libs/distributeddb/common/include/semaphore_utils.h index 6372363f0..9cdb3f561 100755 --- a/services/distributeddataservice/libs/distributeddb/common/include/semaphore.h +++ b/services/distributeddataservice/libs/distributeddb/common/include/semaphore_utils.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef SEMAPHORE_H -#define SEMAPHORE_H +#ifndef SEMAPHORE_UTILS_H +#define SEMAPHORE_UTILS_H #include #include @@ -23,13 +23,13 @@ #include "macro_utils.h" namespace DistributedDB { -class Semaphore { +class SemaphoreUtils { public: - explicit Semaphore(int count); - ~Semaphore(); + explicit SemaphoreUtils(int count); + ~SemaphoreUtils(); // Delete the copy and assign constructors - DISABLE_COPY_ASSIGN_MOVE(Semaphore); + DISABLE_COPY_ASSIGN_MOVE(SemaphoreUtils); bool WaitSemaphore(int waitSecond); diff --git a/services/distributeddataservice/libs/distributeddb/common/src/auto_launch.cpp b/services/distributeddataservice/libs/distributeddb/common/src/auto_launch.cpp index a1bc6fb68..1354f8ee4 100755 --- a/services/distributeddataservice/libs/distributeddb/common/src/auto_launch.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/auto_launch.cpp @@ -24,7 +24,7 @@ #include "kvdb_manager.h" #include "kv_store_changed_data_impl.h" #include "sync_able_kvdb_connection.h" -#include "semaphore.h" +#include "semaphore_utils.h" #include "kv_store_nb_conflict_data_impl.h" #include "db_common.h" #include "param_check_utils.h" @@ -561,7 +561,7 @@ void AutoLaunch::GetConnInDoOpenMap(std::map &doOpe if (doOpenMap.empty()) { return; } - Semaphore sema(1 - doOpenMap.size()); + SemaphoreUtils sema(1 - doOpenMap.size()); for (auto &iter : doOpenMap) { int errCode = RuntimeContext::GetInstance()->ScheduleTask([&sema, &iter, this] { int errCode; diff --git a/services/distributeddataservice/libs/distributeddb/common/src/semaphore.cpp b/services/distributeddataservice/libs/distributeddb/common/src/semaphore_utils.cpp similarity index 73% rename from services/distributeddataservice/libs/distributeddb/common/src/semaphore.cpp rename to services/distributeddataservice/libs/distributeddb/common/src/semaphore_utils.cpp index f2ef2096a..f2ab5388d 100755 --- a/services/distributeddataservice/libs/distributeddb/common/src/semaphore.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/semaphore_utils.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "semaphore.h" +#include "semaphore_utils.h" #include @@ -22,39 +22,39 @@ using std::unique_lock; using std::mutex; using std::condition_variable; -Semaphore::Semaphore(int count) +SemaphoreUtils::SemaphoreUtils(int count) : count_(count) {} -Semaphore::~Semaphore() +SemaphoreUtils::~SemaphoreUtils() {} -bool Semaphore::WaitSemaphore(int waitSecond) +bool SemaphoreUtils::WaitSemaphore(int waitSecond) { unique_lock lock(lockMutex_); bool result = cv_.wait_for(lock, std::chrono::seconds(waitSecond), - std::bind(&Semaphore::CompareCount, this)); + std::bind(&SemaphoreUtils::CompareCount, this)); if (result == true) { --count_; } return result; } -void Semaphore::WaitSemaphore() +void SemaphoreUtils::WaitSemaphore() { unique_lock lock(lockMutex_); - cv_.wait(lock, std::bind(&Semaphore::CompareCount, this)); + cv_.wait(lock, std::bind(&SemaphoreUtils::CompareCount, this)); --count_; } -void Semaphore::SendSemaphore() +void SemaphoreUtils::SendSemaphore() { unique_lock lock(lockMutex_); count_++; cv_.notify_one(); } -bool Semaphore::CompareCount() const +bool SemaphoreUtils::CompareCount() const { return count_ > 0; } diff --git a/services/distributeddataservice/libs/distributeddb/communicator/include/frame_combiner.h b/services/distributeddataservice/libs/distributeddb/communicator/include/frame_combiner.h index b2a2bd049..0fe738698 100755 --- a/services/distributeddataservice/libs/distributeddb/communicator/include/frame_combiner.h +++ b/services/distributeddataservice/libs/distributeddb/communicator/include/frame_combiner.h @@ -19,7 +19,7 @@ #include #include #include -#include "semaphore.h" +#include "semaphore_utils.h" #include "macro_utils.h" #include "parse_result.h" #include "combine_status.h" @@ -68,7 +68,7 @@ private: TimerId timerId_ = 0; // 0 is invalid timerId bool isTimerWork_ = false; - Semaphore timerRemovedIndicator_{0}; + SemaphoreUtils timerRemovedIndicator_{0}; uint64_t incProgressId_ = 0; uint64_t totalSizeByByte_ = 0; std::map> combineWorkPool_; diff --git a/services/distributeddataservice/libs/distributeddb/syncer/include/sync_operation.h b/services/distributeddataservice/libs/distributeddb/syncer/include/sync_operation.h index 995526d1f..913252f4f 100755 --- a/services/distributeddataservice/libs/distributeddb/syncer/include/sync_operation.h +++ b/services/distributeddataservice/libs/distributeddb/syncer/include/sync_operation.h @@ -24,7 +24,7 @@ #include "ikvdb_sync_interface.h" #include "ref_object.h" -#include "semaphore.h" +#include "semaphore_utils.h" #include "notification_chain.h" #include "runtime_context.h" @@ -148,7 +148,7 @@ private: bool isFinished_; // Used for block sync - std::unique_ptr semaphore_; + std::unique_ptr semaphore_; }; } // namespace DistributedDB diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_sync_state_machine.h b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_sync_state_machine.h index 27f69eba7..44d5733d7 100755 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_sync_state_machine.h +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_sync_state_machine.h @@ -21,7 +21,7 @@ #include "sync_state_machine.h" #include "sync_target.h" -#include "semaphore.h" +#include "semaphore_utils.h" #include "message.h" #include "single_ver_sync_task_context.h" #include "time_sync.h" diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/sync_operation.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/sync_operation.cpp index bc26dda79..e5c6996fd 100755 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/sync_operation.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/sync_operation.cpp @@ -55,7 +55,7 @@ int SyncOperation::Initialize() } if (isBlockSync_) { - semaphore_ = std::make_unique(0); + semaphore_ = std::make_unique(0); } return E_OK; diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/sync_task_context.h b/services/distributeddataservice/libs/distributeddb/syncer/src/sync_task_context.h index b293f4523..3a542cafe 100755 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/sync_task_context.h +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/sync_task_context.h @@ -21,7 +21,7 @@ #include "isync_task_context.h" #include "sync_target.h" -#include "semaphore.h" +#include "semaphore_utils.h" #include "sync_operation.h" #include "icommunicator.h" #include "ikvdb_sync_interface.h" diff --git a/services/distributeddataservice/libs/distributeddb/test/BUILD.gn b/services/distributeddataservice/libs/distributeddb/test/BUILD.gn index 36adae090..10dffa5ac 100755 --- a/services/distributeddataservice/libs/distributeddb/test/BUILD.gn +++ b/services/distributeddataservice/libs/distributeddb/test/BUILD.gn @@ -85,7 +85,7 @@ ohos_source_set("src_file") { "../common/src/runtime_context_impl.cpp", "../common/src/schema_object.cpp", "../common/src/schema_utils.cpp", - "../common/src/semaphore.cpp", + "../common/src/semaphore_utils.cpp", "../common/src/task_pool.cpp", "../common/src/task_pool_impl.cpp", "../common/src/task_queue.cpp", @@ -439,8 +439,8 @@ ohos_unittest("DistributedDBStorageEncryptTest") { ] ldflags = [ "-Wl,--exclude-libs,ALL" ] deps = [ - "//third_party/openssl:libcrypto_static", "//third_party/googletest:gtest_main", + "//third_party/openssl:libcrypto_static", "//utils/native/base:utils", ] } -- Gitee