pub struct RuntimeGuard { /* private fields */ }Implementations§
Source§impl RuntimeGuard
impl RuntimeGuard
pub fn new() -> Self
Sourcepub async fn runtime_ticker(&self) -> RuntimeTicker
pub async fn runtime_ticker(&self) -> RuntimeTicker
Create a ticker for the caller and connect it to the control fan-out.
Examples found in repository?
examples/dynamic_add.rs (line 41)
36 fn process_start(&self) -> ProcFuture<'_> {
37 let id = self.id;
38 let guard = self.guard.clone();
39
40 Box::pin(async move {
41 let ticker = guard.runtime_ticker().await;
42 let mut beat = interval(Duration::from_secs(1));
43
44 loop {
45 match ticker.tick(beat.tick()).await {
46 ProcessOperation::Next(_) => println!("worker-{id}: heartbeat"),
47 ProcessOperation::Control(RuntimeControlMessage::Reload) => {
48 println!("worker-{id}: received *reload*")
49 }
50 ProcessOperation::Control(RuntimeControlMessage::Shutdown) => {
51 println!("worker-{id}: shutting down");
52 break;
53 }
54 // absorb any future control messages we don't explicitly handle
55 ProcessOperation::Control(_) => continue,
56 }
57 }
58 Ok(())
59 })
60 }More examples
examples/simple.rs (line 39)
34 fn process_start(&self) -> ProcFuture<'_> {
35 let id = self.id;
36 let guard = self.guard.clone();
37
38 Box::pin(async move {
39 let ticker = guard.runtime_ticker().await;
40 let mut tic = interval(Duration::from_secs(1));
41
42 loop {
43 match ticker.tick(tic.tick()).await {
44 ProcessOperation::Next(_) => {
45 println!("worker-{id}: heartbeat");
46 }
47 ProcessOperation::Control(RuntimeControlMessage::Reload) => {
48 println!("worker-{id}: received *reload*");
49 }
50 ProcessOperation::Control(RuntimeControlMessage::Shutdown) => {
51 println!("worker-{id}: shutting down");
52 break;
53 }
54 // absorb any future control messages we don't explicitly handle
55 ProcessOperation::Control(_) => continue,
56 }
57 }
58 Ok(())
59 })
60 }pub async fn is_running(&self) -> bool
Sourcepub fn handle(&self) -> Arc<dyn ProcessControlHandler>
pub fn handle(&self) -> Arc<dyn ProcessControlHandler>
Examples found in repository?
More examples
Sourcepub async fn block_until_shutdown(&self)
pub async fn block_until_shutdown(&self)
Busy-wait helper for tests / demos.
Trait Implementations§
Source§impl Clone for RuntimeGuard
impl Clone for RuntimeGuard
Source§fn clone(&self) -> RuntimeGuard
fn clone(&self) -> RuntimeGuard
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RuntimeGuard
impl Debug for RuntimeGuard
Source§impl Default for RuntimeGuard
impl Default for RuntimeGuard
impl Send for RuntimeGuard
impl Sync for RuntimeGuard
Auto Trait Implementations§
impl Freeze for RuntimeGuard
impl !RefUnwindSafe for RuntimeGuard
impl Unpin for RuntimeGuard
impl !UnwindSafe for RuntimeGuard
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more