Skip to content
Open
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
46 changes: 46 additions & 0 deletions bbqueue/src/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,52 @@ impl<S: Storage, C: Coord, N: Notifier> crate::queue::ArcBBQueue<S, C, N> {
}
}

/// Create a new [`FramedProducer`] for this [`BBQueue`] with a custom
/// frame length header type.
///
/// This can be used to support large frame sizes by selecting a larger
/// [`LenHeader`](crate::prod_cons::framed::LenHeader) type such as
/// `usize`.
///
/// The `H` header type MUST match the `H` used to create the paired
/// [`FramedConsumer`] (typically via
/// [`framed_consumer_with_header`](Self::framed_consumer_with_header)).
/// Header width is not stored in the queue itself, so a mismatch will
/// silently corrupt framing rather than producing a compile-time or
/// runtime error. Mixing framed with stream producers/consumers will not
/// result in UB either, but will also not work correctly.
pub fn framed_producer_with_header<H: crate::prod_cons::framed::LenHeader>(
&self,
) -> FramedProducer<alloc::sync::Arc<BBQueue<S, C, N>>, H> {
FramedProducer {
bbq: self.0.bbq_ref(),
pd: PhantomData,
}
}

/// Create a new [`FramedConsumer`] for this [`BBQueue`] with a custom
/// frame length header type.
///
/// This can be used to support large frame sizes by selecting a larger
/// [`LenHeader`](crate::prod_cons::framed::LenHeader) type such as
/// `usize`.
///
/// The `H` header type MUST match the `H` used to create the paired
/// [`FramedProducer`] (typically via
/// [`framed_producer_with_header`](Self::framed_producer_with_header)).
/// Header width is not stored in the queue itself, so a mismatch will
/// silently corrupt framing rather than producing a compile-time or
/// runtime error. Mixing framed with stream producers/consumers will not
/// result in UB either, but will also not work correctly.
pub fn framed_consumer_with_header<H: crate::prod_cons::framed::LenHeader>(
&self,
) -> FramedConsumer<alloc::sync::Arc<BBQueue<S, C, N>>, H> {
FramedConsumer {
bbq: self.0.bbq_ref(),
pd: PhantomData,
}
}

/// Create a new [`StreamProducer`] for this [`BBQueue`]
///
/// Although mixing stream and framed consumer/producers will not result in UB,
Expand Down
Loading