feat!: Reason about Send/Sync-ness of types and change Rcs to Arcs#488
Merged
johanneskoester merged 3 commits intorust-bio:masterfrom Dec 19, 2025
Merged
Conversation
Pull Request Test Coverage Report for Build 20367476991Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
e211ed9 to
907dabb
Compare
johanneskoester
approved these changes
Dec 19, 2025
Contributor
|
The lint is already fixed in the master branch. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is an attempt to make the library a bit more usable in a multi-threaded setting. I started to replace
Rc<T>s withArc<T>s where the wrapper type is supposed to be Send and/or Sync [1]. Of course, since we work with raw C-pointers andhtslibin the background, it is quite the task to actually reason about thread-safety, so the assumption so far is that the C methods behave reasonable™. I need to mention that I am not very familiar with the underlying C code. So far, this PR also does not nearly solve all the problems related to thread-safety, frankly, it might introduce more. For example, I added Send/Sync implementations for someHeadertypes, the soundness of which I have not really verified.This all is motivated by the use of the library in my own multi-threaded program, and of course is therefore biased to what would be convenient for me (Send/Sync on Header or Reader/Writer types for example.) For getting a Send/Sync Reader/Writer, it is of course also possible to just create Wrapper types.
Maybe this will inspire some people to continue working on this, or I will do once I find the time. Maybe, this will even revive the discussion about how to solve this issue in general. I am very open to suggestions/discussions.
There are multiple issues that are mentioning this, most importantly maybe #293 .
[1] The performance penalty is, in my opinion, absolutely tolerable and greatly outweighs having to deal with segfault when doing something "simple" as using a parrallel iterator.