From 2064a09b2c330a032940e46d85b9ce8a5639047b Mon Sep 17 00:00:00 2001 From: "Ram.Type-0" Date: Mon, 17 Jan 2022 22:58:12 +0900 Subject: [PATCH 1/2] Implement `Send` for chunk types #4 --- src/chunks.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/chunks.rs b/src/chunks.rs index dad49ba9..48ddd59d 100644 --- a/src/chunks.rs +++ b/src/chunks.rs @@ -444,6 +444,8 @@ pub struct WriteChunkUninit<'a, T> { producer: &'a Producer, } +unsafe impl Send for WriteChunkUninit<'_, T> {} + impl WriteChunkUninit<'_, T> { /// Returns two slices for writing to the requested slots. /// @@ -614,6 +616,8 @@ pub struct ReadChunk<'a, T> { consumer: &'a mut Consumer, } +unsafe impl Send for ReadChunk<'_, T> {} + impl ReadChunk<'_, T> { /// Returns two slices for reading from the requested slots. /// From d7c6bdb413acbdf55238d761854fa4c3164b5403 Mon Sep 17 00:00:00 2001 From: "Ram.Type-0" <39725073+RamType0@users.noreply.github.com> Date: Mon, 28 Feb 2022 16:57:52 +0900 Subject: [PATCH 2/2] Add comments about `Send` safety for chunk types Co-authored-by: Matthias Geier --- src/chunks.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/chunks.rs b/src/chunks.rs index 48ddd59d..38128cac 100644 --- a/src/chunks.rs +++ b/src/chunks.rs @@ -444,6 +444,8 @@ pub struct WriteChunkUninit<'a, T> { producer: &'a Producer, } +// WriteChunkUninit only exists while a unique reference to the Producer is held. +// It is therefore safe to move it to another thread. unsafe impl Send for WriteChunkUninit<'_, T> {} impl WriteChunkUninit<'_, T> { @@ -616,6 +618,8 @@ pub struct ReadChunk<'a, T> { consumer: &'a mut Consumer, } +// ReadChunk only exists while a unique reference to the Consumer is held. +// It is therefore safe to move it to another thread. unsafe impl Send for ReadChunk<'_, T> {} impl ReadChunk<'_, T> {