Skip to content

Commit

Permalink
Improve FifoChannel and RingChannel docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Mallets committed Sep 18, 2024
1 parent b5d798d commit 57ab880
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
10 changes: 7 additions & 3 deletions zenoh/src/api/handlers/fifo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@ use std::sync::Arc;

use crate::api::handlers::{callback::Callback, IntoHandler, API_DATA_RECEPTION_CHANNEL_SIZE};

/// The default handler in Zenoh is a FIFO queue.
/// An handler implementing FIFO semantics.
///
/// Note that pushing on a full [`FifoChannel`] that is full will block until a slot is available.
/// E.g., a slow subscriber could block the underlying Zenoh thread because is not emptying the
/// [`FifoChannel`] fast enough. In this case, you may want to look into [`crate::api::handlers::RingChannel`] that
/// will drop samples when full.
pub struct FifoChannel {
capacity: usize,
}

impl FifoChannel {
/// Initialize the RingBuffer with the capacity size.
/// Initialize the [`FifoChannel`] with the capacity size.
pub fn new(capacity: usize) -> Self {
Self { capacity }
}
Expand Down
3 changes: 3 additions & 0 deletions zenoh/src/api/handlers/ring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ use crate::api::{
};

/// A synchronous ring channel with a limited size that allows users to keep the last N data.
///
/// [`RingChannel`] implements FIFO semantics with a dropping strategy when full.
/// The oldest elements will be dropped when newer arrive.
pub struct RingChannel {
capacity: usize,
}
Expand Down

0 comments on commit 57ab880

Please sign in to comment.