use {Notify, Port, Future};
impl<T:Sized> Port<T> {
pub fn set(self, value: T) {
*self.contents.lock()
.expect("Lock of the future is poisoned") = Some(value);
self.channel.send(Notify::Fsm(self.token))
.expect("Target channel for the future is full");
}
}
impl<T:Sized> Future<T> {
pub fn get(self) -> T {
self.contents.lock().expect("Lock of the future is poisoned")
.take().expect("Future is not resolved yet")
}
pub fn done(&self) -> bool {
self.contents.lock()
.expect("Lock of the future is poisoned").is_some()
}
}