1#![doc = include_str!("../README.md")]
2
3mod mutex;
4mod rw_lock;
5
6pub use mutex::{Mutex, UntilUnlocked, WriteGuard};
7pub use rw_lock::{ReadGuard, RwLock};
8
9use std::{
10 cell::UnsafeCell,
11 future::Future,
12 hash::Hash,
13 pin::Pin,
14 task::Waker,
15 task::{Context, Poll},
16};
17
18pub(crate) type Map<K, V> = std::sync::Mutex<std::collections::HashMap<K, V>>;
19pub(crate) fn new_map<K, V>() -> std::sync::Mutex<std::collections::HashMap<K, V>> {
20 std::sync::Mutex::new(std::collections::HashMap::new())
21}
22
23pub(crate) enum PollState {
24 Init,
25 Pending,
26 Ready,
27}
28macro_rules! ret_fut {
29 ($state: expr, $body: block) => {
30 unsafe {
31 match $state {
32 PollState::Init => {
33 $body;
34 $state = PollState::Pending;
35 }
36 PollState::Ready => return Poll::Ready(()),
37 _ => {}
38 };
39 return Poll::Pending;
40 }
41 };
42}
43pub(crate) use ret_fut;