diff options
Diffstat (limited to 'src/util/promise.rs')
-rw-r--r-- | src/util/promise.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/util/promise.rs b/src/util/promise.rs index 63fbca1ddc18..22f1e8b47f58 100644 --- a/src/util/promise.rs +++ b/src/util/promise.rs @@ -3,9 +3,11 @@ use std::pin::Pin; use std::sync::{Arc, RwLock}; use std::task::{Context, Poll, Waker}; +type Waiter<Env, T> = Box<dyn Fn(&mut Env, &T)>; + pub struct Promise<Env, T> { inner: Arc<RwLock<Inner<T>>>, - waiters: Arc<RwLock<Vec<Box<dyn Fn(&mut Env, &T)>>>>, + waiters: Arc<RwLock<Vec<Waiter<Env, T>>>>, } pub struct Complete<T> { @@ -29,7 +31,7 @@ pub fn promise<Env, T>() -> (Complete<T>, Promise<Env, T>) { inner: inner.clone(), waiters: Arc::new(RwLock::new(Vec::new())), }; - let complete = Complete { inner: inner }; + let complete = Complete { inner }; (complete, promise) } @@ -127,7 +129,7 @@ impl<Env, P: Give<Env>> Give<Env> for &P { impl<Env, T> Future for Promise<Env, T> { type Output = Arc<T>; - fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> { + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { let mut inner = self.inner.write().unwrap(); match inner.value { Some(ref v) => Poll::Ready(v.clone()), |