Skip to content

Commit

Permalink
Mark OdbReader and OdbWriter Send (#765)
Browse files Browse the repository at this point in the history
The underlying `git_odb_stream` objects don't do anything that would
prevent moving them to another thread and continuing to operate on them,
as long as the original thread can no longer touch them.
  • Loading branch information
joshtriplett committed Nov 15, 2021
1 parent 33b14ce commit 979d2d5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/odb.rs
Expand Up @@ -326,6 +326,10 @@ pub struct OdbReader<'repo> {
_marker: marker::PhantomData<Object<'repo>>,
}

// `git_odb_stream` is not thread-safe internally, so it can't use `Sync`, but moving it to another
// thread and continuing to read will work.
unsafe impl<'repo> Send for OdbReader<'repo> {}

impl<'repo> Binding for OdbReader<'repo> {
type Raw = *mut raw::git_odb_stream;

Expand Down Expand Up @@ -367,6 +371,10 @@ pub struct OdbWriter<'repo> {
_marker: marker::PhantomData<Object<'repo>>,
}

// `git_odb_stream` is not thread-safe internally, so it can't use `Sync`, but moving it to another
// thread and continuing to write will work.
unsafe impl<'repo> Send for OdbWriter<'repo> {}

impl<'repo> OdbWriter<'repo> {
/// Finish writing to an ODB stream
///
Expand Down

0 comments on commit 979d2d5

Please sign in to comment.