crb_actor/
interrupt.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use crate::actor::Actor;
use crate::message::MessageFor;
use crate::runtime::Address;
use anyhow::Result;
use async_trait::async_trait;

impl<A: Actor> Address<A> {
    pub fn interrupt(&self) -> Result<()> {
        self.send(Interrupt)
    }
}

struct Interrupt;

#[async_trait]
impl<A: Actor> MessageFor<A> for Interrupt {
    async fn handle(self: Box<Self>, actor: &mut A, ctx: &mut A::Context) -> Result<()> {
        actor.interrupt(ctx).await
    }
}