Skip to content

Commit

Permalink
Merge pull request #7 from re-gmbh/fix/thread-sleep
Browse files Browse the repository at this point in the history
Get rid of thread::sleep in async client
  • Loading branch information
phlay authored May 2, 2024
2 parents 7673228 + 3aaf568 commit 87a3d6e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/src/async_client/comms/tcp_transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,14 +342,14 @@ impl TcpTransport {
}

/// Disconnects the stream from the server (if it is connected)
pub fn wait_for_disconnect(&self) {
pub async fn wait_for_disconnect(&self) {
debug!("Waiting for a disconnect");
loop {
if self.connection_state.is_finished() {
debug!("Disconnected");
break;
}
thread::sleep(Duration::from_millis(Self::WAIT_POLLING_TIMEOUT))
sleep(Duration::from_millis(Self::WAIT_POLLING_TIMEOUT)).await;
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/src/async_client/session/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ impl Session {
session_state.quit();
}

self.transport.wait_for_disconnect();
self.transport.wait_for_disconnect().await;
self.on_connection_status_change(false);
}
}
Expand Down

0 comments on commit 87a3d6e

Please sign in to comment.