zaeleus / noodles

Bioinformatics I/O libraries in Rust
MIT License
477 stars 53 forks source link

`Send`-able `Repository`? #234

Closed tshauck closed 6 months ago

tshauck commented 6 months ago

Hi, thanks as always for this library.

I'm seeking help in understanding how or if I could use the Repository associated with a CRAM file in Send-able fashion? Repository is a tuple struct: pub struct Repository(Rc<RwLock<AdapterCache>>), and I think Rc isn't Send-able (which may make this a non-starter).

FWIW, the end goal is to stream records similar to this example: https://github.com/zaeleus/noodles/blob/adb6f05cb9a08116bb9f89b9ee4dcf7a1ff469aa/noodles-cram/examples/cram_view_async.rs though I can share a better example if it'd be helpful.

Any advice you could give toward that end would be helpful, thanks!

zaeleus commented 6 months ago

Thanks for reporting! Repository was intended to allow concurrent access, which is why the adapter has a readers-writer lock.

noodles 0.65.0 / noodles-fasta 0.33.0 makes Repository thread-safe (i.e., Send + Sync).

tshauck commented 6 months ago

Thanks!