Skip to content

Commit

Permalink
Implement Send for chunk types (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
RamType0 authored Mar 3, 2022
1 parent d6d8fe1 commit 7279fc1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/chunks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,10 @@ pub struct WriteChunkUninit<'a, T> {
producer: &'a Producer<T>,
}

// WriteChunkUninit only exists while a unique reference to the Producer is held.
// It is therefore safe to move it to another thread.
unsafe impl<T: Send> Send for WriteChunkUninit<'_, T> {}

impl<T> WriteChunkUninit<'_, T> {
/// Returns two slices for writing to the requested slots.
///
Expand Down Expand Up @@ -615,6 +619,10 @@ pub struct ReadChunk<'a, T> {
consumer: &'a Consumer<T>,
}

// ReadChunk only exists while a unique reference to the Consumer is held.
// It is therefore safe to move it to another thread.
unsafe impl<T: Send> Send for ReadChunk<'_, T> {}

impl<T> ReadChunk<'_, T> {
/// Returns two slices for reading from the requested slots.
///
Expand Down

0 comments on commit 7279fc1

Please sign in to comment.