Last active
January 8, 2017 01:29
-
-
Save Zoxc/49e3afaf928104852661e3038ea6854c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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