# lace-ws
The result of a Bachelor thesis around porting the [C lace work-stealing library](https://github.com/trolando/lace) to rust while trying to keep Rust's safety guarantees.
We could surpass Rayon's efficiency on the benchmarks mentioned in the C lace paper, at some ergonomic cost.
This project works well enough to do the experiments necessary for the thesis, it was tested with threadsanitizer and MIRI, so it *should* be (relatively) bug-free. Adjust your expectations of quality to match the fact that this was done in a couple of weeks with the focus on doing the experiments and exploring the safety-speed tradeoff.
I do not expect to maintain this code, but I also don't expect the dependencies to undergo any breaking changes anytime soon so it *should* still work when you're reading this (though maybe with more warnings).
# example
```
use lace_ws::{Lace, Worker, lace_task, lace_run};
const N: usize = 40;
#[lace_task]
fn fib(n: usize) -> usize {
if n < 2 {
n
} else {
let (a, b) = join!(fib(n-1), fib(n-2));
a + b
}
}
fn main() {
let mut lace = Lace::init(4);
let fib_n = lace_run!(lace, fib(N));
println!("fib({N}) = {fib_n}");
}
```
functions marked `lace_task` may use `join!(call1, call2)`, or a `tkn = spawn!(call)`, `result = sync!(tkn)` API. To call a `lace_task` from another `lace_task` synchronously, there is `call!(call))`.