Skip to content

Commit

Permalink
fix duration for small network sizees
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-maron committed Feb 12, 2024
1 parent 7c49757 commit b302de8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
13 changes: 13 additions & 0 deletions broker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,19 @@ where

info!("received connection from user {:?}", connection_id.data());

// If we have a small amount of users, send the updates immediately
if get_lock!(inner.user_connection_lookup, read).get_connection_count() < 50 {
// TODO NEXT: Move this into just asking the task nicely to do it
let _ = inner
.send_updates_to_brokers(
vec![],
get_lock!(inner.broker_connection_lookup, read)
.get_all_connections()
.clone(),
)
.await;
}

// This runs the main loop for receiving information from the user
let () = inner.user_recv_loop(connection_id, receiver).await;

Expand Down
5 changes: 1 addition & 4 deletions client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,7 @@ async fn main() -> Result<()> {
})
.await?,
);

// Wait 5 seconds so broker has time to propagate info about us
sleep(Duration::from_secs(5)).await;


// Run our first client, which sends a message to our second.
let client1 = spawn(async move {
// Clone our client
Expand Down

0 comments on commit b302de8

Please sign in to comment.