1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#![doc = include_str!("../README.md")]
#![warn(missing_docs)]
#![warn(rustdoc::missing_crate_level_docs)]
//! # The Locking methods
//!
//! There are plenty flavors on how a lock can be obtained. The normal blocking way, trying to
//! obtain a lock, possibly with timeouts, allow a thread to lock a single RwLock multiple
//! times. These are (zero-cost) abstracted here.

pub use parking_lot::{
    Mutex, MutexGuard, ReentrantMutex, ReentrantMutexGuard, RwLock, RwLockReadGuard,
    RwLockWriteGuard,
};
/// reexport for convenience
pub use std::time::{Duration, Instant};

/// Marker for blocking locks,
/// waits until the lock becomes available.
pub struct Blocking;

/// Marker for trying to obtain a lock in a fallible way.
pub struct TryLock;

/// Marker for recursive locking. Allows to obtain a read-lock multiple times by a single
/// thread.
pub struct Recursive<T>(pub T);

mod readlock_method;
pub use readlock_method::*;

mod writelock_method;
pub use writelock_method::*;

mod mutex_method;
pub use mutex_method::*;

mod reentrant_mutex_method;
pub use reentrant_mutex_method::*;