pub struct OwnedSemaphorePermit { /* private fields */ }Expand description
An owned permit from the semaphore.
This type is created by the acquire_owned method.
Implementations§
Source§impl OwnedSemaphorePermit
impl OwnedSemaphorePermit
Sourcepub fn forget(self)
pub fn forget(self)
Forgets the permit without releasing it back to the semaphore.
This can be used to permanently reduce the number of permits available from a semaphore.
§Examples
use std::sync::Arc;
use mea::semaphore::Semaphore;
let sem = Arc::new(Semaphore::new(10));
{
let permit = sem.try_acquire(5).unwrap();
assert_eq!(sem.available_permits(), 5);
permit.forget();
}
// Since we forgot the permit, available permits won't go back to
// its initial value even after the permit is dropped
assert_eq!(sem.available_permits(), 5);Trait Implementations§
Source§impl Debug for OwnedSemaphorePermit
impl Debug for OwnedSemaphorePermit
Auto Trait Implementations§
impl Freeze for OwnedSemaphorePermit
impl RefUnwindSafe for OwnedSemaphorePermit
impl Send for OwnedSemaphorePermit
impl Sync for OwnedSemaphorePermit
impl Unpin for OwnedSemaphorePermit
impl UnwindSafe for OwnedSemaphorePermit
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more