pub unsafe trait BatchReader {
type Item;
// Required methods
fn read_buffer(&mut self) -> &[Self::Item];
unsafe fn advance(&mut self, n: usize);
// Provided method
unsafe fn release(&mut self) { ... }
}Expand description
Trait for queue receivers that support batch read operations.
§Safety
Implementations must ensure:
read_bufferreturns a valid slice of initialized items that remain valid untiladvanceis calledadvancepublishes the new head to the producer (atomic store + wake)releasereleases any held resources (e.g., shard locks), and is a no-op when no resources are held
§Ownership
Items are returned by shared reference — ownership is not transferred
to the caller. advance makes slots reusable by
the producer but does not drop the previous values. For types that
implement Drop, use ReadGuard::drain_into or the ReadGuard
iterator to take ownership; plain
ReadGuard::as_slice combined with ReadGuard::advance will skip
the items’ destructors.
Required Associated Types§
Required Methods§
Sourcefn read_buffer(&mut self) -> &[Self::Item]
fn read_buffer(&mut self) -> &[Self::Item]
Returns a slice of available contiguous items.
Items are returned by shared reference — ownership is not transferred. See the trait-level ownership note.
Provided Methods§
Implementors§
Source§impl<T> BatchReader for gil::mpmc::sharded::Receiver<T>
§Safety
The implementation locks a shard spinlock in read_buffer
and releases it in release. Between these two
calls, no other receiver can access the locked shard.
impl<T> BatchReader for gil::mpmc::sharded::Receiver<T>
§Safety
The implementation locks a shard spinlock in read_buffer
and releases it in release. Between these two
calls, no other receiver can access the locked shard.
Items are returned by shared reference — ownership is not transferred.
See BatchReader for details.
Source§impl<T> BatchReader for gil::mpsc::sharded::Receiver<T>
§Safety
The implementation delegates to the per-shard SPSC receivers.
read_buffer polls shards round-robin and returns the first non-empty
contiguous slice. advance publishes the new head on the active shard.
impl<T> BatchReader for gil::mpsc::sharded::Receiver<T>
§Safety
The implementation delegates to the per-shard SPSC receivers.
read_buffer polls shards round-robin and returns the first non-empty
contiguous slice. advance publishes the new head on the active shard.
Items are returned by shared reference — ownership is not transferred.
See BatchReader for details.
Source§impl<T> BatchReader for gil::mpsc::sharded_parking::Receiver<T>
§Safety
The implementation delegates to per-shard SPSC QueuePtrs.
read_buffer polls shards round-robin and returns the first non-empty
contiguous slice. advance publishes the new head and wakes parked senders.
impl<T> BatchReader for gil::mpsc::sharded_parking::Receiver<T>
§Safety
The implementation delegates to per-shard SPSC QueuePtrs.
read_buffer polls shards round-robin and returns the first non-empty
contiguous slice. advance publishes the new head and wakes parked senders.
Source§impl<T> BatchReader for gil::spmc::sharded::Receiver<T>
§Safety
The implementation delegates to the single shard’s SPSC QueuePtr.
impl<T> BatchReader for gil::spmc::sharded::Receiver<T>
§Safety
The implementation delegates to the single shard’s SPSC QueuePtr.
Source§impl<T> BatchReader for gil::spmc::sharded_parking::Receiver<T>
§Safety
The implementation delegates to the single shard’s SPSC QueuePtr.
impl<T> BatchReader for gil::spmc::sharded_parking::Receiver<T>
§Safety
The implementation delegates to the single shard’s SPSC QueuePtr.
Source§impl<T> BatchReader for gil::spsc::parking::Receiver<T>
§Safety
The implementation delegates to the queue’s atomic head/tail for synchronisation.
read_buffer refreshes the cached tail and returns a contiguous slice from
the ring buffer. advance publishes the new head via a Release store and
wakes the sender via futex.
impl<T> BatchReader for gil::spsc::parking::Receiver<T>
§Safety
The implementation delegates to the queue’s atomic head/tail for synchronisation.
read_buffer refreshes the cached tail and returns a contiguous slice from
the ring buffer. advance publishes the new head via a Release store and
wakes the sender via futex.
Source§impl<T> BatchReader for gil::spsc::Receiver<T>
§Safety
The implementation delegates to the queue’s atomic head/tail for synchronisation.
read_buffer refreshes the cached tail and returns a contiguous slice from
the ring buffer. advance publishes the new head via a Release store and
wakes the sender when the async feature is enabled.
impl<T> BatchReader for gil::spsc::Receiver<T>
§Safety
The implementation delegates to the queue’s atomic head/tail for synchronisation.
read_buffer refreshes the cached tail and returns a contiguous slice from
the ring buffer. advance publishes the new head via a Release store and
wakes the sender when the async feature is enabled.