1
0
mirror of https://github.com/fafhrd91/actix-net synced 2024-11-27 16:52:58 +01:00

Add alive method on arbiter

This commit is contained in:
Emile Fugulin 2024-05-10 12:43:54 -04:00
parent 943ddcd37e
commit 4a6322ba34
2 changed files with 15 additions and 0 deletions

View File

@ -3,6 +3,7 @@
## Unreleased
- Add `actix_rt::ArbiterBuilder` to allow user to configure the thread spawned for the arbiter.
- Add `Arbiter::alive` and `ArbiterHandle::alive` to check is the arbiter is still alive.
## 2.10.0

View File

@ -71,6 +71,13 @@ impl ArbiterHandle {
self.spawn(async { f() })
}
/// Check if the [Arbiter] is still alive.
///
/// Returns false if the [Arbiter] has been dropped, returns true otherwise.
pub fn alive(&self) -> bool {
!self.tx.is_closed()
}
/// Instruct [Arbiter] to stop processing it's event loop.
///
/// Returns true if stop message was sent successfully and false if the [Arbiter] has
@ -367,6 +374,13 @@ impl Arbiter {
self.spawn(async { f() })
}
/// Check if the [Arbiter] is still alive.
///
/// Returns false if the [Arbiter] has been dropped, returns true otherwise.
pub fn alive(&self) -> bool {
!self.tx.is_closed()
}
/// Wait for Arbiter's event loop to complete.
///
/// Joins the underlying OS thread handle. See [`JoinHandle::join`](thread::JoinHandle::join).