Skip to content

Commit

Permalink
Add alive method on arbiter
Browse files Browse the repository at this point in the history
  • Loading branch information
Sytten committed Oct 28, 2024
1 parent 943ddcd commit 4a6322b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions actix-rt/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 14 additions & 0 deletions actix-rt/src/arbiter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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).
Expand Down

0 comments on commit 4a6322b

Please sign in to comment.