Struct classic_sync::semaphore::SemaphoreError
source · pub struct SemaphoreError { /* private fields */ }Implementations§
source§impl SemaphoreError
impl SemaphoreError
Wrapper of sem_t in c. Providing Semaphore access without mut access. It is super easy to share!
Example:
use std::sync::Arc;
use std::time::Duration;
use std::thread;
use classic_sync::semaphore::Semaphore;
let sem = Semaphore::new(3); // allows 3 concurrent access
let arc_sem = Arc::new(sem);
for i in 0..3 {
let sem_copy = Arc::clone(&arc_sem);
let tid = i;
thread::spawn(move || {
sem_copy.p();
println!("Now I am granted access. I should have 2 other siblings has the access at the same time!");
std::thread::sleep(Duration::from_secs(3));
// Other people can't acquire the lock even when I am sleeping.
sem_copy.v(); // You have to manually unlock it to release the lock
});
}Trait Implementations§
source§impl Debug for SemaphoreError
impl Debug for SemaphoreError
source§impl Display for SemaphoreError
impl Display for SemaphoreError
source§impl Error for SemaphoreError
impl Error for SemaphoreError
1.30.0 · source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
The lower-level source of this error, if any. Read more
1.0.0 · source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Auto Trait Implementations§
impl RefUnwindSafe for SemaphoreError
impl Send for SemaphoreError
impl Sync for SemaphoreError
impl Unpin for SemaphoreError
impl UnwindSafe for SemaphoreError
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