|
|
|
@ -68,9 +68,10 @@ impl Initialiser
|
|
|
|
|
pub async fn wait(&mut self) -> Result<(), InitWaitError>
|
|
|
|
|
{
|
|
|
|
|
if !*self.rx.borrow() {
|
|
|
|
|
self.rx.recv().await
|
|
|
|
|
.ok_or_else(|| InitWaitError)
|
|
|
|
|
.and_then(|x| if x {Ok(())} else {Err(InitWaitError)})
|
|
|
|
|
while !self.rx.recv().await.ok_or_else(|| InitWaitError)? {
|
|
|
|
|
tokio::task::yield_now().await;
|
|
|
|
|
}
|
|
|
|
|
Ok(())
|
|
|
|
|
} else {
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
@ -95,14 +96,8 @@ impl Future for Initialiser
|
|
|
|
|
{
|
|
|
|
|
type Output = Result<(), InitWaitError>;
|
|
|
|
|
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
|
|
|
|
|
|
|
|
|
if !*self.rx.borrow() {
|
|
|
|
|
let rx = self.rx.recv();
|
|
|
|
|
tokio::pin!(rx);
|
|
|
|
|
rx.poll(cx).map(|x| x.ok_or_else(|| InitWaitError)
|
|
|
|
|
.and_then(|x| if x {Ok(())} else {Err(InitWaitError)}))
|
|
|
|
|
} else {
|
|
|
|
|
Poll::Ready(Ok(()))
|
|
|
|
|
}
|
|
|
|
|
let uhh = self.wait();
|
|
|
|
|
tokio::pin!(uhh);
|
|
|
|
|
uhh.poll(cx)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|