Skip to content

Instantly share code, notes, and snippets.

@Zoxc
Last active January 8, 2017 01:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zoxc/49e3afaf928104852661e3038ea6854c to your computer and use it in GitHub Desktop.
Save Zoxc/49e3afaf928104852661e3038ea6854c to your computer and use it in GitHub Desktop.
// 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