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