Skip to content

Commit

Permalink
Update wrappers docs
Browse files Browse the repository at this point in the history
  • Loading branch information
agerasev committed Jan 20, 2024
1 parent e972ab0 commit 98599b9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/wrap/caching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ pub type CachingProd<R> = Caching<R, true, false>;
pub type CachingCons<R> = Caching<R, false, true>;

impl<R: RbRef, const P: bool, const C: bool> Caching<R, P, C> {
/// # Safety
/// Create a new ring buffer cached wrapper.
///
/// There must be no more than one consumer wrapper.
/// Panics if wrapper with matching rights already exists.
pub fn new(rb: R) -> Self {
Self { frozen: Frozen::new(rb) }
}
Expand Down
4 changes: 2 additions & 2 deletions src/wrap/direct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ impl<R: RbRef> Clone for Obs<R> {
}

impl<R: RbRef, const P: bool, const C: bool> Direct<R, P, C> {
/// # Safety
/// Create a new ring buffer direct wrapper.
///
/// There must be no more than one wrapper with the same parameter being `true`.
/// Panics if wrapper with matching rights already exists.
pub fn new(rb: R) -> Self {
if P {
assert!(!unsafe { rb.rb().hold_write(true) });
Expand Down
6 changes: 4 additions & 2 deletions src/wrap/frozen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ pub type FrozenProd<R> = Frozen<R, true, false>;
pub type FrozenCons<R> = Frozen<R, false, true>;

impl<R: RbRef, const P: bool, const C: bool> Frozen<R, P, C> {
/// Create new ring buffer cache.
/// Create a new ring buffer frozen wrapper.
///
/// Panics if wrapper with matching rights already exists.
pub fn new(rb: R) -> Self {
if P {
assert!(!unsafe { rb.rb().hold_write(true) });
Expand All @@ -53,7 +55,7 @@ impl<R: RbRef, const P: bool, const C: bool> Frozen<R, P, C> {
///
/// # Safety
///
/// There must be maximum one instance of producer and one - of consumer.
/// There must be maximum one instance of matching rights.
pub(crate) unsafe fn new_unchecked(rb: R) -> Self {
Self {
read: Cell::new(rb.rb().read_index()),
Expand Down

0 comments on commit 98599b9

Please sign in to comment.