slide-rs / fibe-rs

Fiberized task queue in Rust
Apache License 2.0
11 stars 0 forks source link

Future concept #23

Open kvark opened 9 years ago

kvark commented 9 years ago

We could have a Future trait for the following things:

ghost commented 9 years ago

It may look like this: http://dwrensha.github.io/capnproto-rust/2015/05/25/asynchronous-io-with-promises.html

ghost commented 9 years ago

With futures it would be nice if we had an api to make it easy to start tasks when futures are ready.

// return a future
let foo = task(|_| 0u32).start(sched);

// start this task when the task is done
// this creates a barrier on all the futures and enqueues the task
// when the future list is ready
let bar = on_complete!(sched, |sched, foo| {
  println!("{}", something);
});
//ect ect ect
let baz = on_complete!(sched, |sched, bar| {});