many fixes for bootstrap and public internet connectivity

This commit is contained in:
John Smith
2022-05-24 17:13:52 -04:00
parent 9a54ee052c
commit 424ceedfd8
26 changed files with 606 additions and 320 deletions
+15 -10
View File
@@ -2,38 +2,43 @@ use super::*;
pub struct SingleShotEventual<T>
where
T: Unpin + Clone,
T: Unpin,
{
eventual: EventualValueClone<T>,
drop_value: T,
eventual: EventualValue<T>,
drop_value: Option<T>,
}
impl<T> Drop for SingleShotEventual<T>
where
T: Unpin + Clone,
T: Unpin,
{
fn drop(&mut self) {
self.eventual.resolve(self.drop_value.clone());
if let Some(drop_value) = self.drop_value.take() {
self.eventual.resolve(drop_value);
}
}
}
impl<T> SingleShotEventual<T>
where
T: Unpin + Clone,
T: Unpin,
{
pub fn new(drop_value: T) -> Self {
pub fn new(drop_value: Option<T>) -> Self {
Self {
eventual: EventualValueClone::new(),
eventual: EventualValue::new(),
drop_value,
}
}
// Can only call this once, it consumes the eventual
pub fn resolve(self, value: T) -> EventualResolvedFuture<EventualValueClone<T>> {
pub fn resolve(mut self, value: T) -> EventualResolvedFuture<EventualValue<T>> {
// If we resolve, we don't want to resolve again to the drop value
self.drop_value = None;
// Resolve to the specified value
self.eventual.resolve(value)
}
pub fn instance(&self) -> EventualValueCloneFuture<T> {
pub fn instance(&self) -> EventualValueFuture<T> {
self.eventual.instance()
}
}