remove sender clone

feed
Avril 4 years ago
parent 59dcecded3
commit bcaac2b2e3
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -64,7 +64,37 @@ impl Initialiser
rx, rx,
} }
} }
pub fn into_wait(self) -> impl Future<Output=Result<(), InitWaitError>> + 'static
{
let mut rx = self.rx;
async move {
if !*rx.borrow() {
while !rx.recv().await.ok_or_else(|| InitWaitError)? {
//tokio::task::yield_now().await;
}
Ok(())
} else {
Ok(())
}
}
}
pub fn clone_into_wait(&self) -> impl Future<Output=Result<(), InitWaitError>> + 'static
{
let mut rx = self.rx.clone();
async move {
if !*rx.borrow() {
while !rx.recv().await.ok_or_else(|| InitWaitError)? {
//tokio::task::yield_now().await;
}
Ok(())
} else {
Ok(())
}
}
}
pub async fn wait(&mut self) -> Result<(), InitWaitError> pub async fn wait(&mut self) -> Result<(), InitWaitError>
{ {
if !*self.rx.borrow() { if !*self.rx.borrow() {

@ -60,9 +60,8 @@ impl State
if self.has_shutdown() { if self.has_shutdown() {
return Err(ShutdownError); return Err(ShutdownError);
} }
let mut begin = self.begin.clone(); tokio::select! {
tokio::select!{ //fuck Ok(()) = self.begin.clone_into_wait() => Ok(()),
Ok(()) = begin.wait() => Ok(()),
_ = self.on_shutdown() => { _ = self.on_shutdown() => {
debug!("on_init(): shutdown received"); debug!("on_init(): shutdown received");
Err(ShutdownError) Err(ShutdownError)

Loading…
Cancel
Save