Skip to content

Instantly share code, notes, and snippets.

@Zoxc Zoxc/future.rs
Last active Jan 8, 2017

Embed
What would you like to do?
// A function pointer and some data to pass to the callback
pub struct Callback<R> {
pointer: fn (R, *const ()),
data: *const (),
}
// This is the trait implemented for generators
pub trait Future {
type Return;
// This starts the computation. The result will be given by callback
fn schedule<'c>(self, callback: &'c mut Callback<Self::Return>) -> impl ActiveFuture<'c> + ?Move;
}
// This represent an immovable and active computation
pub trait ActiveFuture<'c>: ?Move {
// This cancels the computation
fn cancel(&mut self);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.