Skip to content

Commit

Permalink
using shared
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonYao287 committed Jan 31, 2024
1 parent d9855e4 commit a377770
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/include/homestore/replication/repl_dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ class ReplDevListener {
public:
virtual ~ReplDevListener() = default;

void set_repl_dev(ReplDev* rdev) { m_repl_dev = rdev; }
virtual ReplDev* repl_dev() { return m_repl_dev; }
void set_repl_dev(shared< ReplDev > rdev) { m_repl_dev = rdev; }
virtual shared< ReplDev > repl_dev() { return m_repl_dev.lock(); }

/// @brief Called when the log entry has been committed in the replica set.
///
Expand Down Expand Up @@ -184,7 +184,7 @@ class ReplDevListener {
virtual void on_replica_stop() = 0;

private:
ReplDev* m_repl_dev;
std::weak_ptr< ReplDev > m_repl_dev;
};

class ReplDev {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/replication/service/generic_repl_svc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ AsyncReplResult< shared< ReplDev > > SoloReplService::create_repl_dev(group_id_t
auto rdev = std::make_shared< SoloReplDev >(std::move(rd_sb), false /* load_existing */);

auto listener = m_repl_app->create_repl_dev_listener(group_id);
listener->set_repl_dev(rdev.get());
listener->set_repl_dev(rdev);
rdev->attach_listener(std::move(listener));

{
Expand All @@ -133,7 +133,7 @@ void SoloReplService::load_repl_dev(sisl::byte_view const& buf, void* meta_cooki
auto rdev = std::make_shared< SoloReplDev >(std::move(rd_sb), true /* load_existing */);

auto listener = m_repl_app->create_repl_dev_listener(group_id);
listener->set_repl_dev(rdev.get());
listener->set_repl_dev(rdev);
rdev->attach_listener(std::move(listener));

{
Expand Down
4 changes: 2 additions & 2 deletions src/lib/replication/service/raft_repl_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ void RaftReplService::raft_group_config_found(sisl::byte_view const& buf, void*

auto rdev = std::dynamic_pointer_cast< RaftReplDev >(*v);
auto listener = m_repl_app->create_repl_dev_listener(group_id);
listener->set_repl_dev(rdev.get());
listener->set_repl_dev(rdev);
rdev->attach_listener(std::move(listener));
rdev->use_config(std::move(group_config));
}
Expand Down Expand Up @@ -194,7 +194,7 @@ shared< nuraft_mesg::mesg_state_mgr > RaftReplService::create_state_mgr(int32_t

// Attach the listener to the raft
auto listener = m_repl_app->create_repl_dev_listener(group_id);
listener->set_repl_dev(rdev.get());
listener->set_repl_dev(rdev);
rdev->attach_listener(std::move(listener));

// Add the repl dev to the map
Expand Down

0 comments on commit a377770

Please sign in to comment.