Simple Rust Actors
TODO,
- Load the data that you want to sent to the actor
- Get a Promise back
- Poll the Promise till data is received
let actor_ref = todo!("Get your actor ref");
let mut promise = actor_ref.as_poll(request);
loop {
let _result = promise.poll_once();
if promise.get().is_some() {
// Data has been received
break;
}
}
let data: Option<&Response> = promise.get();// Another way to do the same thing
let actor_ref = todo!("Get your actor ref");
let mut promise = actor_ref.as_poll(request);
loop {
let result = promise.poll_once();
if result.is_ok() {
if matches!(res.unwrap(), ActorRefPollInfo::Complete) {
break;
}
}
}
let data: Option<&Response> = promise.get();---
title: Polling good states
---
stateDiagram-v2
Start --> RequestSent: RequestSent
Start --> Start: RequestQueueFull
RequestSent --> RequestSent: ResponseQueueEmpty
RequestSent --> End(ok): Complete
---
title: Polling errors
---
stateDiagram-v2
Start --> End(error): ActorShutdown
RequestSent --> End(error): ActorInternalError
crossbeam-channelhas been used purely for itsselect!macro- If this lands in rust
stdconsider removing dependency on this library
- If this lands in rust