use std::any::Any;
use std::sync::{Arc, Mutex};
use std::sync::mpsc::Sender;
use actors::{Actor, ActorCell, ActorContext, ActorRef};
use actors::props::ActorFactory;
pub struct RootActor;
impl RootActor {
pub fn new(_dummy: ()) -> RootActor {
RootActor
}
}
impl Actor for RootActor {
fn receive(&self, message: Box<Any>, context: ActorCell) {
if let Ok(message) = Box::<Any>::downcast::<(Arc<ActorFactory>, String, Arc<Mutex<Sender<Result<ActorRef, &'static str>>>>)>(message) {
let tmp = *message;
let (props, name, tx) = tmp;
let actor_ref = context.actor_of(props, name);
let _res = tx.lock().unwrap().send(actor_ref);
}
}
}