Skip to content

Commit

Permalink
Qd mpx: also leave some SHM free for splitting
Browse files Browse the repository at this point in the history
  • Loading branch information
sk1p committed Jul 18, 2024
1 parent ff943aa commit 9af7e49
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions libertem_qd_mpx/src/background_thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,14 @@ fn make_frame_stack(
to_thread_r: &Receiver<QdControlMsg>,
) -> Result<FrameStackForWriting<QdFrameMeta>, AcquisitionError> {
loop {
// keep some slots free for splitting frame stacks
if shm.num_slots_free() < 3 && shm.num_slots_total() >= 3 {
trace!("shm is almost full; waiting and creating backpressure...");
check_for_control(to_thread_r)?;
std::thread::sleep(Duration::from_millis(1));
continue;
}

match shm.try_get_mut() {
Ok(slot) => {
return Ok(FrameStackForWriting::new(
Expand Down

0 comments on commit 9af7e49

Please sign in to comment.