Crates.io | ticque |
lib.rs | ticque |
version | 0.1.3 |
source | src |
created_at | 2024-05-21 12:54:03.563 |
updated_at | 2024-05-22 08:35:30.699329 |
description | Take a queue for a resource |
homepage | |
repository | https://github.com/limpix31/ticque |
max_upload_size | |
id | 1246823 |
size | 6,360 |
A pattern that can help request data from a data stream running in a loop
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?;