1use std::{
21 future::Future,
22 pin::Pin,
23 task::{Context, Poll},
24};
25
26use futures::FutureExt;
27
28pub mod event;
29pub use event::*;
30
31pub mod fifo_queue;
32pub use fifo_queue::*;
33
34pub mod lifo_queue;
35pub use lifo_queue::*;
36
37pub mod object_pool;
38pub use object_pool::*;
39
40pub mod mvar;
41pub use mvar::*;
42
43pub mod condition;
44pub use condition::*;
45
46pub mod signal;
47pub use signal::*;
48
49pub mod cache;
50pub use cache::*;
51
52pub fn get_mut_unchecked<T>(arc: &mut std::sync::Arc<T>) -> &mut T {
53 unsafe { &mut (*(std::sync::Arc::as_ptr(arc) as *mut T)) }
54}
55
56#[must_use = "futures do nothing unless you `.await` or poll them"]
58pub struct PinBoxFuture<T>(Pin<Box<dyn Future<Output = T> + Send>>);
59
60impl<T> Future for PinBoxFuture<T> {
61 type Output = T;
62
63 #[inline]
64 fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
65 self.0.poll_unpin(cx)
66 }
67}
68
69#[inline]
70pub fn pinbox<T>(fut: impl Future<Output = T> + Send + 'static) -> PinBoxFuture<T> {
71 PinBoxFuture(Box::pin(fut))
72}