You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the current beta 0.5.0-beta.5, an actor is not automatically dropped when its last Address is dropped.
This behavior can be caused by the following code:
use xtra::prelude::*;
use xtra::spawn::AsyncStd;
struct Printer {
times: usize,
}
impl Printer {
fn new() -> Self {
Printer { times: 0 }
}
}
#[async_trait::async_trait]
impl Actor for Printer {
async fn stopped(&mut self) {
println!("Printer is stopped");
}
}
struct Print(String);
impl Message for Print {
type Result = ();
}
#[async_trait::async_trait]
impl Handler<Print> for Printer {
async fn handle(&mut self, print: Print, _ctx: &mut Context<Self>) {
self.times += 1;
println!("Printing {}. Printed {} times so far.", print.0, self.times);
}
}
#[async_std::main]
async fn main() {
{
let addr = Printer::new().create(None).spawn(&mut AsyncStd);
addr.send(Print("hello".to_string()))
.await
.expect("Printer should not be dropped");
}
println!("Printer should be dropped here");
}
With this code, Printer is actually never dropped, even until the application stops.
This is probably because of refcount.rs line 74, where the strong refcount is checked against ==2.
It's only 1 in the example, though.
The text was updated successfully, but these errors were encountered:
In the current beta
0.5.0-beta.5
, an actor is not automatically dropped when its lastAddress
is dropped.This behavior can be caused by the following code:
With this code, Printer is actually never dropped, even until the application stops.
This is probably because of refcount.rs line 74, where the strong refcount is checked against
==2
.It's only
1
in the example, though.The text was updated successfully, but these errors were encountered: