noodles icon indicating copy to clipboard operation
noodles copied to clipboard

Implement Send + Sync on key structs?

Open nh13 opened this issue 2 years ago • 1 comments

I wanted to use rayon to parallelize some of my processing, but found that I need to have the Send + Sync traits for key structs, like a Bed record and BAM record. Is there any appetite for adding those, and/or figuring out which are safe to send and share across threads?

 bed_reader.records::<6>().par_bridge()

nh13 avatar Jul 20 '22 09:07 nh13

The data containers are Send + Sync. See the auto trait implementations for sam::alignment::Record and bed::Record<N>.

Looking at ParallelBridge, the iterator is also required to be Send. This is not possible for bed::Reader::records<N> because it captures Self<R> as a mutable reference. You can, however, move the reader into your own iterator to create a producer.

zaeleus avatar Jul 20 '22 15:07 zaeleus