From 29d570f05765b6676b6dd1ae1e0fc65e9d1e0bf1 Mon Sep 17 00:00:00 2001 From: Brian Szmyd Date: Thu, 28 Sep 2023 19:22:01 -0700 Subject: [PATCH] Remove unncessary atomic --- src/lib/homeobject_impl.hpp | 2 +- src/lib/homestore_backend/hs_homeobject.hpp | 2 +- src/lib/homestore_backend/hs_pg_manager.cpp | 6 +++--- src/lib/homestore_backend/hs_shard_manager.cpp | 2 +- src/lib/memory_backend/mem_pg_manager.cpp | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/lib/homeobject_impl.hpp b/src/lib/homeobject_impl.hpp index 9b0be613..bec2fe64 100644 --- a/src/lib/homeobject_impl.hpp +++ b/src/lib/homeobject_impl.hpp @@ -98,7 +98,7 @@ class HomeObjectImpl : public HomeObject, /// mutable std::shared_mutex _pg_lock; - std::map< pg_id_t, shared< PG > > _pg_map; + std::map< pg_id_t, unique< PG > > _pg_map; mutable std::shared_mutex _shard_lock; std::map< shard_id_t, ShardIterator > _shard_map; diff --git a/src/lib/homestore_backend/hs_homeobject.hpp b/src/lib/homestore_backend/hs_homeobject.hpp index 8b6e8169..395f6f28 100644 --- a/src/lib/homestore_backend/hs_homeobject.hpp +++ b/src/lib/homestore_backend/hs_homeobject.hpp @@ -71,7 +71,7 @@ class HSHomeObject : public HomeObjectImpl { void register_homestore_metablk_callback(); void* get_shard_metablk(shard_id_t id); void on_pg_meta_blk_found(sisl::byte_view const& buf, void* meta_cookie); - void add_pg_to_map(shared< HS_PG > hs_pg); + void add_pg_to_map(unique< HS_PG > hs_pg); public: using HomeObjectImpl::HomeObjectImpl; diff --git a/src/lib/homestore_backend/hs_pg_manager.cpp b/src/lib/homestore_backend/hs_pg_manager.cpp index 2dfe776a..888adec8 100644 --- a/src/lib/homestore_backend/hs_pg_manager.cpp +++ b/src/lib/homestore_backend/hs_pg_manager.cpp @@ -52,7 +52,7 @@ PGManager::NullAsyncResult HSHomeObject::_create_pg(PGInfo&& pg_info, std::set< .create_repl_dev(pg_info.replica_set_uuid, std::move(peers), std::make_unique< ReplicationStateMachine >(this)) .thenValue([this, pg_info = std::move(pg_info)](auto&& v) -> PGManager::NullResult { if (v.hasError()) { return folly::makeUnexpected(toPgError(v.error())); } - add_pg_to_map(std::make_shared< HS_PG >(std::move(pg_info), std::move(v.value()))); + add_pg_to_map(std::make_unique< HS_PG >(std::move(pg_info), std::move(v.value()))); return folly::Unit(); }); } @@ -62,7 +62,7 @@ PGManager::NullAsyncResult HSHomeObject::_replace_member(pg_id_t id, peer_id_t c return folly::makeSemiFuture< PGManager::NullResult >(folly::makeUnexpected(PGError::UNSUPPORTED_OP)); } -void HSHomeObject::add_pg_to_map(shared< HS_PG > hs_pg) { +void HSHomeObject::add_pg_to_map(unique< HS_PG > hs_pg) { RELEASE_ASSERT(hs_pg->pg_info_.replica_set_uuid == hs_pg->repl_dev_->group_id(), "PGInfo replica set uuid mismatch with ReplDev instance for {}", boost::uuids::to_string(hs_pg->pg_info_.replica_set_uuid)); @@ -120,7 +120,7 @@ void HSHomeObject::on_pg_meta_blk_found(sisl::byte_view const& buf, void* meta_c LOGE("open_repl_dev for group_id={} has failed", boost::uuids::to_string(pg_sb->replica_set_uuid)); return; } - add_pg_to_map(std::make_shared< HS_PG >(pg_sb, std::move(v.value()))); + add_pg_to_map(std::make_unique< HS_PG >(pg_sb, std::move(v.value()))); }); } diff --git a/src/lib/homestore_backend/hs_shard_manager.cpp b/src/lib/homestore_backend/hs_shard_manager.cpp index 0c49480a..ea363e0b 100644 --- a/src/lib/homestore_backend/hs_shard_manager.cpp +++ b/src/lib/homestore_backend/hs_shard_manager.cpp @@ -66,7 +66,7 @@ ShardManager::Result< ShardInfo > HSHomeObject::_create_shard(pg_id_t pg_owner, LOGW("failed to create shard with non-exist pg [{}]", pg_owner); return folly::makeUnexpected(ShardError::UNKNOWN_PG); } - repl_dev = std::static_pointer_cast< HS_PG >(iter->second)->repl_dev_; + repl_dev = static_cast< HS_PG* >(iter->second.get())->repl_dev_; } if (!repl_dev) { LOGW("failed to get repl dev instance for pg [{}]", pg_owner); diff --git a/src/lib/memory_backend/mem_pg_manager.cpp b/src/lib/memory_backend/mem_pg_manager.cpp index d57145ae..0762d7d6 100644 --- a/src/lib/memory_backend/mem_pg_manager.cpp +++ b/src/lib/memory_backend/mem_pg_manager.cpp @@ -3,7 +3,7 @@ namespace homeobject { PGManager::NullAsyncResult MemoryHomeObject::_create_pg(PGInfo&& pg_info, std::set< std::string, std::less<> >) { auto lg = std::scoped_lock(_pg_lock); - auto [it1, _] = _pg_map.try_emplace(pg_info.id, std::make_shared< PG >(pg_info)); + auto [it1, _] = _pg_map.try_emplace(pg_info.id, std::make_unique< PG >(pg_info)); RELEASE_ASSERT(_pg_map.end() != it1, "Unknown map insert error!"); return folly::makeSemiFuture< PGManager::NullResult >(folly::Unit()); } @@ -12,4 +12,4 @@ PGManager::NullAsyncResult MemoryHomeObject::_replace_member(pg_id_t id, peer_id PGMember const& new_member) { return folly::makeSemiFuture< PGManager::NullResult >(folly::makeUnexpected(PGError::UNSUPPORTED_OP)); } -} // namespace homeobject \ No newline at end of file +} // namespace homeobject