Skip to content

Commit 979d2d5

Browse files
authored
Mark OdbReader and OdbWriter Send (#765)
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.
1 parent 33b14ce commit 979d2d5

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/odb.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,10 @@ pub struct OdbReader<'repo> {
326326
_marker: marker::PhantomData<Object<'repo>>,
327327
}
328328

329+
// `git_odb_stream` is not thread-safe internally, so it can't use `Sync`, but moving it to another
330+
// thread and continuing to read will work.
331+
unsafe impl<'repo> Send for OdbReader<'repo> {}
332+
329333
impl<'repo> Binding for OdbReader<'repo> {
330334
type Raw = *mut raw::git_odb_stream;
331335

@@ -367,6 +371,10 @@ pub struct OdbWriter<'repo> {
367371
_marker: marker::PhantomData<Object<'repo>>,
368372
}
369373

374+
// `git_odb_stream` is not thread-safe internally, so it can't use `Sync`, but moving it to another
375+
// thread and continuing to write will work.
376+
unsafe impl<'repo> Send for OdbWriter<'repo> {}
377+
370378
impl<'repo> OdbWriter<'repo> {
371379
/// Finish writing to an ODB stream
372380
///

0 commit comments

Comments
 (0)