bplevin36 / syncbuf

A small library of append-only, thread-safe, lock-free data structures.
MIT License
5 stars 2 forks source link

impl par_iter #3

Open bestouff opened 3 years ago

bestouff commented 3 years ago

Would it be possible to implement par_iter rom rayon ?
Sorry no PR for this one ...

bplevin36 commented 4 months ago

This would be nifty, but a fairly niche optimization. Assuming you already have a populated Synclist named sl , you can do this in user code like:

use rayon::iter::ParallelBridge;
use rayon::prelude::ParallelIterator;
...
let parallel_iterator = (0..).map_while(|i| sl.get(i)).par_bridge();
...

This might not be as performant as a bespoke implementation of the traits from rayon, but it will observe concurrent pushes to the Synclist and it doesn't require unsafe.