-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added cloning of Senders & Callers, send_later memory leak fix, abort…
…handle return & version bumps
- Loading branch information
1 parent
8bdc08e
commit 5f4006b
Showing
12 changed files
with
267 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use std::time::Duration; | ||
use xactor::*; | ||
|
||
#[message] | ||
struct IntervalMsg; | ||
|
||
struct MyActor; | ||
|
||
#[async_trait::async_trait] | ||
impl Actor for MyActor { | ||
async fn started(&mut self, ctx: &mut Context<Self>) -> Result<()> { | ||
// Send the IntervalMsg message 3 seconds later | ||
ctx.send_later(IntervalMsg, Duration::from_millis(500)); | ||
Ok(()) | ||
} | ||
} | ||
|
||
#[async_trait::async_trait] | ||
impl Handler<IntervalMsg> for MyActor { | ||
async fn handle(&mut self, ctx: &mut Context<Self>, _msg: IntervalMsg) { | ||
ctx.send_later(IntervalMsg, Duration::from_millis(500)); | ||
} | ||
} | ||
|
||
#[xactor::main] | ||
async fn main() -> Result<()> { | ||
// Exit the program after 3 seconds | ||
let addr = MyActor.start().await?; | ||
addr.wait_for_stop().await; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.