fixed minor differences between 'compiled' generators and the example used. Added bonus section to prove it works
This commit is contained in:
@@ -188,7 +188,7 @@ fn main() {
|
||||
reactor.lock().map(|mut r| r.close()).unwrap();
|
||||
}
|
||||
|
||||
//// ===== EXECUTOR =====
|
||||
// ============================= EXECUTOR ====================================
|
||||
fn block_on<F: Future>(mut future: F) -> F::Output {
|
||||
let mywaker = Arc::new(MyWaker{ thread: thread::current() });
|
||||
let waker = waker_into_waker(Arc::into_raw(mywaker));
|
||||
@@ -212,7 +212,7 @@ fn spawn<F: Future>(future: F) -> Pin<Box<F>> {
|
||||
boxed
|
||||
}
|
||||
|
||||
// ===== FUTURE IMPLEMENTATION =====
|
||||
// ====================== FUTURE IMPLEMENTATION ==============================
|
||||
#[derive(Clone)]
|
||||
struct MyWaker {
|
||||
thread: thread::Thread,
|
||||
@@ -280,7 +280,7 @@ impl Future for Task {
|
||||
}
|
||||
}
|
||||
|
||||
// ===== REACTOR =====
|
||||
// =============================== REACTOR ===================================
|
||||
struct Reactor {
|
||||
dispatcher: Sender<Event>,
|
||||
handle: Option<JoinHandle<()>>,
|
||||
@@ -301,7 +301,7 @@ impl Reactor {
|
||||
let handle = thread::spawn(move || {
|
||||
// This simulates some I/O resource
|
||||
for event in rx {
|
||||
println!("GOT EVENT: {:?}", event);
|
||||
println!("REACTOR: {:?}", event);
|
||||
let rl_clone = rl_clone.clone();
|
||||
match event {
|
||||
Event::Close => break,
|
||||
|
||||
Reference in New Issue
Block a user