Skip to content

Commit

Permalink
heartbeat: Improve locking
Browse files Browse the repository at this point in the history
  • Loading branch information
akiradeveloper committed May 25, 2024
1 parent 5c38619 commit f4a1a72
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lolraft/src/communicator/heartbeat_multiplex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ pub async fn run(
loop {
tokio::time::sleep(Duration::from_millis(300)).await;

let states = {
let heartbeats = {
let mut buf = buf.lock();
let heartbeats = buf.drain();
let out = buf.drain();
out
};

let states = {
let mut out = HashMap::new();
for (lane_id, heartbeat) in heartbeats {
let state = raft::LeaderCommitState {
Expand Down

0 comments on commit f4a1a72

Please sign in to comment.