yaar_lock/future/
mod.rs

1use super::sync::WordLock;
2use futures_intrusive::sync::*;
3
4/// A synchronization primitive which can be either in the set or reset state.
5pub type RawResetEvent<ThreadEvent> = GenericManualResetEvent<WordLock<ThreadEvent>>;
6
7/// A Future that is resolved once the corresponding `RawResetEvent` has been
8/// set
9pub type RawWaitForEventFuture<'a, ThreadEvent> =
10    GenericWaitForEventFuture<'a, WordLock<ThreadEvent>>;
11
12/// A futures-aware mutex.
13pub type RawMutex<T, ThreadEvent> = GenericMutex<WordLock<ThreadEvent>, T>;
14
15/// An RAII guard returned by the lock and try_lock methods of `RawMutex`.
16/// When this structure is dropped (falls out of scope), the lock will be
17/// unlocked.
18pub type RawMutexGuard<'a, T, ThreadEvent> = GenericMutexGuard<'a, WordLock<ThreadEvent>, T>;
19
20/// A future which resolves when the target mutex has been successfully
21/// acquired.
22pub type RawMutexLockFuture<'a, T, ThreadEvent> =
23    GenericMutexLockFuture<'a, WordLock<ThreadEvent>, T>;
24
25/// A futures-aware semaphore.
26pub type RawSemaphore<ThreadEvent> = GenericSemaphore<WordLock<ThreadEvent>>;
27
28/// An RAII guard returned by the acquire and try_acquire methods of
29/// `RawSemaphore`.
30pub type RawSemaphoreReleaser<'a, ThreadEvent> =
31    GenericSemaphoreReleaser<'a, WordLock<ThreadEvent>>;
32
33/// A future which resolves when the target semaphore has been successfully
34/// acquired.
35pub type RawSemaphoreAcquireFuture<'a, ThreadEvent> =
36    GenericSemaphoreAcquireFuture<'a, WordLock<ThreadEvent>>;
37
38#[cfg(feature = "os")]
39use super::OsThreadEvent;
40
41/// A [`RawResetEvent`] backed by [`OsThreadEvent`].
42#[cfg(feature = "os")]
43#[cfg_attr(feature = "nightly", doc(cfg(feature = "os")))]
44pub type ResetEvent = RawResetEvent<OsThreadEvent>;
45
46/// A [`RawWaitForEventFuture`] for [`ResetEvent`].
47#[cfg(feature = "os")]
48#[cfg_attr(feature = "nightly", doc(cfg(feature = "os")))]
49pub type WaitForEventFuture<'a> = RawWaitForEventFuture<'a, OsThreadEvent>;
50
51/// A [`RawMutex`] backed by [`OsThreadEvent`].
52#[cfg(feature = "os")]
53#[cfg_attr(feature = "nightly", doc(cfg(feature = "os")))]
54pub type Mutex<T> = RawMutex<T, OsThreadEvent>;
55
56/// A [`RawMutexGuard`] for [`Mutex`].
57#[cfg(feature = "os")]
58#[cfg_attr(feature = "nightly", doc(cfg(feature = "os")))]
59pub type MutexGuard<'a, T> = RawMutexGuard<'a, T, OsThreadEvent>;
60
61/// A [`RawMutexLockFuture`] for [`Mutex`].
62#[cfg(feature = "os")]
63#[cfg_attr(feature = "nightly", doc(cfg(feature = "os")))]
64pub type MutexLockFuture<'a, T> = RawMutexLockFuture<'a, T, OsThreadEvent>;
65
66/// A [`RawSemaphore`] backed by [`OsThreadEvent`].
67#[cfg(feature = "os")]
68#[cfg_attr(feature = "nightly", doc(cfg(feature = "os")))]
69pub type Semaphore = RawSemaphore<OsThreadEvent>;
70
71/// A [`RawSemaphoreReleaser`] for [`Semaphore`].
72#[cfg(feature = "os")]
73#[cfg_attr(feature = "nightly", doc(cfg(feature = "os")))]
74pub type SemaphoreReleaser<'a> = RawSemaphoreReleaser<'a, OsThreadEvent>;
75
76/// A [`RawSemaphoreAcquireFuture`] for [`Semaphore`].
77#[cfg(feature = "os")]
78#[cfg_attr(feature = "nightly", doc(cfg(feature = "os")))]
79pub type SemaphoreAcquireFuture<'a> = RawSemaphoreAcquireFuture<'a, OsThreadEvent>;