MCPcopy Create free account
hub / github.com/RustCV/RustCV / wait_for_sample

Method wait_for_sample

rustcv-backend-msmf/src/stream.rs:526–535  ·  view source on GitHub ↗

Waits for a sample to become available and returns it. Uses a semaphore to track available frames. The semaphore's permits accumulate when frames arrive, ensuring no notifications are missed.

(&self)

Source from the content-addressed store, hash-verified

524 /// Uses a semaphore to track available frames. The semaphore's permits
525 /// accumulate when frames arrive, ensuring no notifications are missed.
526 async fn wait_for_sample(&self) -> Result<SendableSample> {
527 let permit = self.shared.frame_ready.acquire().await.map_err(|e| {
528 CameraError::Io(std::io::Error::other(format!("Semaphore error: {}", e)))
529 })?;
530 permit.forget();
531
532 let mut slot = self.shared.sample_slot.lock().unwrap();
533 slot.take()
534 .ok_or_else(|| CameraError::Io(std::io::Error::other("Frame slot was empty")))
535 }
536}

Callers 1

next_frameMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected