annotate rust/src/main.rs @ 587:646f03870762 rust

trying rust
author Matt Johnston <matt@ucc.asn.au>
date Wed, 14 Dec 2016 00:15:14 +0800
parents
children 038734052b20
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
587
646f03870762 trying rust
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1 extern crate robots;
646f03870762 trying rust
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2
646f03870762 trying rust
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3 mod sensor;
646f03870762 trying rust
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4
646f03870762 trying rust
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5 use std::sync::Arc;
646f03870762 trying rust
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6 use std::time::Duration;
646f03870762 trying rust
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7
646f03870762 trying rust
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8 use robots::actors::{Actor, ActorSystem, ActorCell, ActorContext, Props};
646f03870762 trying rust
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
9
646f03870762 trying rust
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
10 fn main() {
646f03870762 trying rust
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
11 println!("Wort Templog");
646f03870762 trying rust
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
12 let actor_system = ActorSystem::new("templog".to_string());
646f03870762 trying rust
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
13
646f03870762 trying rust
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
14 let props = Props::new(Arc::new(sensor::Sensor::new), ());
646f03870762 trying rust
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
15 let sensor = actor_system.actor_of(props, "sensor".to_string());
646f03870762 trying rust
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
16
646f03870762 trying rust
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
17 actor_system.tell(sensor, "yeah".to_string());
646f03870762 trying rust
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
18
646f03870762 trying rust
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
19 std::thread::sleep(Duration::from_millis(100));
646f03870762 trying rust
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
20 actor_system.shutdown();
646f03870762 trying rust
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
21
646f03870762 trying rust
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
22
646f03870762 trying rust
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
23 }
646f03870762 trying rust
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
24