Skip to content

Commit

Permalink
Remove unncessary atomic
Browse files Browse the repository at this point in the history
  • Loading branch information
szmyd committed Sep 29, 2023
1 parent 8b434ad commit 29d570f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/lib/homeobject_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/homestore_backend/hs_homeobject.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/lib/homestore_backend/hs_pg_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
}
Expand All @@ -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));
Expand Down Expand Up @@ -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())));
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/homestore_backend/hs_shard_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/lib/memory_backend/mem_pg_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand All @@ -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
} // namespace homeobject

0 comments on commit 29d570f

Please sign in to comment.