Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add T: Send for Send/Sync impls of producer/consumer #10

Merged
merged 1 commit into from
Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/mpmc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ pub struct MPMCConsumer<T, B: Buffer<T>> {
queue: Arc<UnsafeCell<MPMCQueue<T, B>>>,
}

unsafe impl<T, B: Buffer<T>> Send for MPMCConsumer<T, B> {}
unsafe impl<T, B: Buffer<T>> Sync for MPMCConsumer<T, B> {}
unsafe impl<T: Send, B: Buffer<T>> Send for MPMCConsumer<T, B> {}
unsafe impl<T: Send, B: Buffer<T>> Sync for MPMCConsumer<T, B> {}

/// Producer end of the queue. Implements the trait `Producer<T>`.
pub struct MPMCProducer<T, B: Buffer<T>> {
queue: Arc<UnsafeCell<MPMCQueue<T, B>>>,
}

unsafe impl<T, B: Buffer<T>> Send for MPMCProducer<T, B> {}
unsafe impl<T, B: Buffer<T>> Sync for MPMCProducer<T, B> {}
unsafe impl<T: Send, B: Buffer<T>> Send for MPMCProducer<T, B> {}
unsafe impl<T: Send, B: Buffer<T>> Sync for MPMCProducer<T, B> {}

/// Creates a new MPMC queue
///
Expand Down
6 changes: 3 additions & 3 deletions src/mpsc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ pub struct MPSCConsumer<T, B: Buffer<T>> {
queue: Arc<UnsafeCell<MPSCQueue<T, B>>>,
}

unsafe impl<T, B: Buffer<T>> Send for MPSCConsumer<T, B> {}
unsafe impl<T: Send, B: Buffer<T>> Send for MPSCConsumer<T, B> {}

/// Producer end of the queue. Implements the trait `Producer<T>`.
pub struct MPSCProducer<T, B: Buffer<T>> {
queue: Arc<UnsafeCell<MPSCQueue<T, B>>>,
}

unsafe impl<T, B: Buffer<T>> Send for MPSCProducer<T, B> {}
unsafe impl<T, B: Buffer<T>> Sync for MPSCProducer<T, B> {}
unsafe impl<T: Send, B: Buffer<T>> Send for MPSCProducer<T, B> {}
unsafe impl<T: Send, B: Buffer<T>> Sync for MPSCProducer<T, B> {}

/// Creates a new MPSC queue
///
Expand Down
8 changes: 4 additions & 4 deletions src/spmc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ pub struct SPMCConsumer<T, B: Buffer<T>> {
queue: Arc<UnsafeCell<SPMCQueue<T, B>>>,
}

unsafe impl<T, B: Buffer<T>> Send for SPMCConsumer<T, B> {}
unsafe impl<T, B: Buffer<T>> Sync for SPMCConsumer<T, B> {}
unsafe impl<T: Send, B: Buffer<T>> Send for SPMCConsumer<T, B> {}
unsafe impl<T: Send, B: Buffer<T>> Sync for SPMCConsumer<T, B> {}

/// Producer end of the queue. Implements the trait `Producer<T>`.
pub struct SPMCProducer<T, B: Buffer<T>> {
queue: Arc<UnsafeCell<SPMCQueue<T, B>>>,
}

unsafe impl<T, B: Buffer<T>> Send for SPMCProducer<T, B> {}
unsafe impl<T, B: Buffer<T>> Sync for SPMCProducer<T, B> {}
unsafe impl<T: Send, B: Buffer<T>> Send for SPMCProducer<T, B> {}
unsafe impl<T: Send, B: Buffer<T>> Sync for SPMCProducer<T, B> {}

/// Creates a new SPMC queue
///
Expand Down
4 changes: 2 additions & 2 deletions src/spsc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ pub struct SPSCConsumer<T, B: Buffer<T>> {
queue: Arc<UnsafeCell<SPSCQueue<T, B>>>,
}

unsafe impl<T, B: Buffer<T>> Send for SPSCConsumer<T, B> {}
unsafe impl<T: Send, B: Buffer<T>> Send for SPSCConsumer<T, B> {}

/// Producer end of the queue. Implements the trait `Producer<T>`.
pub struct SPSCProducer<T, B: Buffer<T>> {
queue: Arc<UnsafeCell<SPSCQueue<T, B>>>,
}

unsafe impl<T, B: Buffer<T>> Send for SPSCProducer<T, B> {}
unsafe impl<T: Send, B: Buffer<T>> Send for SPSCProducer<T, B> {}

/// Creates a new SPSC queue
///
Expand Down