mod condvar;
mod graphs;
pub mod lock_manager;
mod mutex;
mod rwlock;
pub use condvar::Condvar;
pub use mutex::{Mutex, MutexGuard};
pub use rwlock::{RwLock, RwLockReadGuard, RwLockWriteGuard};
pub mod prelude {
pub use crate::{Condvar, Mutex, MutexGuard, RwLock, RwLockReadGuard, RwLockWriteGuard};
}
pub mod prelude_std {
pub use std::sync::{Condvar, Mutex, MutexGuard, RwLock, RwLockReadGuard, RwLockWriteGuard};
}
#[cfg(feature = "use_vecmap")]
pub(crate) type Set<T> = vector_map::VecMap<T, ()>;
#[cfg(not(feature = "use_vecmap"))]
pub(crate) type Set<T> = std::collections::HashMap<T, ()>;
#[cfg(feature = "use_vecmap")]
pub(crate) type Map<K, V> = vector_map::VecMap<K, V>;
#[cfg(not(feature = "use_vecmap"))]
pub(crate) type Map<K, V> = std::collections::HashMap<K, V>;
#[test]
fn reported_issue_5() {
use crate::Mutex;
use std::sync::Arc;
let mut childs = vec![];
let m = Arc::new(Mutex::new(0));
for _ in 1..=10 {
let clone_m = m.clone();
childs.push(std::thread::spawn(move || {
let mut m = clone_m.lock().unwrap();
std::thread::sleep(std::time::Duration::from_millis(100));
*m = 1;
}))
}
for c in childs.into_iter() {
c.join().unwrap();
}
}