1
0
mirror of https://github.com/fafhrd91/actix-net synced 2025-06-27 02:47:43 +02:00

add arbiter handle assoc fn (#274)

* add arbiter handle assoc fn
This commit is contained in:
Rob Ede
2021-02-06 22:27:56 +00:00
committed by GitHub
parent 7ee42b50b4
commit eb4d29e15e
3 changed files with 31 additions and 1 deletions

View File

@ -172,13 +172,18 @@ impl Arbiter {
hnd
}
/// Return a handle to the this Arbiter's message sender.
pub fn handle(&self) -> ArbiterHandle {
ArbiterHandle::new(self.tx.clone())
}
/// Return a handle to the current thread's Arbiter's message sender.
///
/// # Panics
/// Panics if no Arbiter is running on the current thread.
pub fn current() -> ArbiterHandle {
HANDLE.with(|cell| match *cell.borrow() {
Some(ref addr) => addr.clone(),
Some(ref hnd) => hnd.clone(),
None => panic!("Arbiter is not running."),
})
}