ticque

Crates.ioticque
lib.rsticque
version0.1.3
sourcesrc
created_at2024-05-21 12:54:03.563
updated_at2024-05-22 08:35:30.699329
descriptionTake a queue for a resource
homepage
repositoryhttps://github.com/limpix31/ticque
max_upload_size
id1246823
size6,360
Danil Karpenko (LIMPIX31)

documentation

README

ticque

A pattern that can help request data from a data stream running in a loop

Example

use ticque::{Vendor, Customer};

let vendor = Vendor::new();
let consumer = vendor.consumer();

tokio::spawn(async move {
  let camera_stream = ...;

  loop {
    let frame = camera_stream.next().await?;

    if vendor.has_waiters() {
      let rgb_image = frame_to_rgb(frame)?;
      vendor.send(rgb_image);
    }
  }
});

let current_rgb_image = consumer.request().await?;
Commit count: 6

cargo fmt