priority_semaphore/
permit.rs

1//! RAII guard returned by [`PrioritySemaphore::acquire`].
2
3use crate::semaphore::PrioritySemaphore;
4use alloc::sync::Arc;
5
6/// Returned by successful acquire; releases permit on `Drop`.
7#[derive(Debug)]
8pub struct Permit {
9    root: Arc<PrioritySemaphore>,
10}
11
12impl Permit {
13    pub(crate) fn new(root: Arc<PrioritySemaphore>) -> Self {
14        Self { root }
15    }
16}
17
18impl Drop for Permit {
19    fn drop(&mut self) {
20        // Give permit back and wake next waiter
21        self.root.dispatch_next();
22    }
23}