clean up veilid state processing

This commit is contained in:
John Smith
2022-01-18 18:28:22 -05:00
parent 1b6864bf22
commit 205a6a8fd1
5 changed files with 54 additions and 41 deletions

View File

@@ -333,11 +333,6 @@ impl AttachmentManager {
}
}
pub async fn send_state_update(&self) {
let attachment_machine = self.inner.lock().attachment_machine.clone();
attachment_machine.send_state_update().await;
}
pub async fn request_attach(&self) {
if !self.is_detached() {
trace!("attach request ignored");
@@ -395,10 +390,8 @@ impl AttachmentManager {
} else {
return false;
}
} else {
if eventual.await == state {
break;
}
} else if eventual.await == state {
break;
}
}
true

View File

@@ -68,24 +68,12 @@ where
// pub fn clear_state_change_callback(&self) {
// self.inner.lock().callback = None;
// }
pub fn state_eventual_instance(&self) -> (T::State, EventualValueCloneFuture<T::State>) {
let inner = self.inner.lock();
(inner.state, inner.eventual.instance())
}
pub async fn send_state_update(&self) {
let (state, callback, eventual) = {
let mut inner = self.inner.lock();
let eventual =
core::mem::replace(&mut inner.eventual, EventualValueClone::<T::State>::new());
(inner.state, inner.callback.clone(), eventual)
};
if let Some(cb) = callback {
cb(state, state).await;
}
eventual.resolve(state).await;
}
pub async fn consume(&self, input: &T::Input) -> Result<Option<T::Output>, ()> {
let current_state = self.inner.lock().state;