kvark / choir

Task Orchestration Framework
MIT License
52 stars 3 forks source link

Relax forked tasks lifetimes #26

Closed kvark closed 2 years ago

kvark commented 2 years ago

This PR introduces a mechanism for having non-static task bodies. In particular, when forking tasks, we can guarantee that their closures will die before the parent closure dies. This drastically improves the qsort case ergonomics.

Draft because it needs a careful look at safety, and doesn't work yet:

thread 'worker1' panicked at 'called `Option::unwrap()` on a `None` value', src/lib.rs:267:26
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: PoisonError { .. }', src/lib.rs:510:50
thread 'worker2' panicked at 'called `Result::unwrap()` on an `Err` value: PoisonError { .. }', src/lib.rs:260:58
kvark commented 2 years ago

This doesn't work because we are eagerly dropping the functions/closures regardless of what forked tasks are doing.

kvark commented 2 years ago

Also, looks like this approach is a no-go. FnOnce body is dropped on execution, so we can't hold the associated data longer.