I've stumbled upon the need for the following synchronization logic:
I'm keeping track of a series of ordered 'tasks' (
T + Ord) with unknown time of completion. I need a thread-safe structure that lets me 'block' an execution context until all tasks in the queue up to a certain point have finished.
This is my current implementation of such a structure.
First of all, I'm honestly astonished at Rust's existing synchronization primitives and the ease with which I was able to write such a structure and for it to compile and sort of work on the first run!
However, I'm unhappy with my removal method
queue.retain(|x| !ptr::eq(x, pointer)); and I think there's a better way to approach this.
My project relies very heavily on parallelism and I believe my current performance is bottlenecked by IO. Because of this I'll be migrating it to Tokio. My question is, does tokio provide a similar abstraction for my needs or could it be done in a much cleaner/faster way?