DEV Community

Discussion on: Rust futures: an uneducated, short and hopefully not boring tutorial - Part 3 - The reactor

Collapse
 
inzanez profile image
inzanez

Hi

many thanks for that tutorial, really interesting! I just got one question:

You state the reactor parks our future in case we return

Ok(Async::NotReady)

But here, you seem to notify the reactor to unpark before we return Ok(Async::NotReady):

println!("not ready yet --> {:?}", self);
futures::task::current().notify();
Ok(Async::NotReady)

So the reactor gets a notification to unpark something that's not yet been parked, doesn't it? ;-)

Collapse
 
mindflavor profile image
Francesco Cogno

Ah yes it's true.
It's an horrible way of simulating the external unpark command :)

Ideally this command should be issued by another "entity" (for example the OS in case of async IO).