remove sender clone

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

@ -65,6 +65,36 @@ impl Initialiser
}
}
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>
{
if !*self.rx.borrow() {

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

Loading…
Cancel
Save