Skip to content

Instantly share code, notes, and snippets.

@th0rex
Created June 6, 2018 17:09
Show Gist options
  • Save th0rex/b283a4db82a2fd72e00c684da7254d40 to your computer and use it in GitHub Desktop.
Save th0rex/b283a4db82a2fd72e00c684da7254d40 to your computer and use it in GitHub Desktop.
#[async(boxed, send)]
fn program_main(state: State) -> Result<(), Never> {
// Hack to make sure sessions is only created on the polling thread.
await!(futures::future::ok::<(), Never>(()))?;
let mut sessions: Vec<Session> = vec![];
#[async]
for cmd in state.command_rx {
use UICommand::*;
match cmd {
Load(x) => {
trace!("load {}", x);
let mut file = File::open(&x).expect("could not open file");
let cm: ClientMessage =
bincode::deserialize_from(&mut file).expect("corrupted file");
match cm {
ClientMessage::Snapshot { regions } => {
let idx = sessions.len();
sessions.push(Session::new(ams::graph_from_snapshot(regions)));
// TODO: Spawn function on UI thread here.
}
_ => unreachable!(),
}
}
CalcPointers(x) => {
trace!("calc pointers {}", x);
}
FindPointerTo(x, y) => trace!("find pointers to {} {}", x, y),
}
}
Ok(())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment