From 7e4af94f5903a63171753c2b3844e475a77be942 Mon Sep 17 00:00:00 2001 From: Vasilito Date: Wed, 6 May 2026 13:05:04 +0100 Subject: [PATCH] docs: document Mutex drop pattern in composite_buffer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The compositor is single-threaded — Mutex guards exist only for Rust borrow-safety. Raw pointers from Vec::as_mut_ptr() remain valid after guard drop because no concurrent mutation is possible. --- local/recipes/wayland/redbear-compositor/source/src/main.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/local/recipes/wayland/redbear-compositor/source/src/main.rs b/local/recipes/wayland/redbear-compositor/source/src/main.rs index 218089409..472d8ac7c 100644 --- a/local/recipes/wayland/redbear-compositor/source/src/main.rs +++ b/local/recipes/wayland/redbear-compositor/source/src/main.rs @@ -1096,6 +1096,10 @@ impl Compositor { } fn composite_buffer(&self, pool: &mut ShmPool, buffer: &Buffer, surface: &Surface) { + // The compositor is single-threaded (handle_client is blocking). + // Mutex guards are used only for Rust borrow-safety; raw pointers + // obtained from Vec::as_mut_ptr() remain valid after the guard is + // dropped because no other thread can mutate the buffers. let byte_count = buffer.height as usize * buffer.stride as usize; if buffer.offset as usize + byte_count > pool.size { return; }