initial import of main veilid core

This commit is contained in:
John Smith
2021-11-22 11:28:30 -05:00
parent c4cd54e020
commit 9e94a6a96f
218 changed files with 34880 additions and 1 deletions
@@ -0,0 +1,39 @@
use super::*;
pub struct SingleShotEventual<T>
where
T: Unpin + Clone,
{
eventual: EventualValueClone<T>,
drop_value: T,
}
impl<T> Drop for SingleShotEventual<T>
where
T: Unpin + Clone,
{
fn drop(&mut self) {
self.eventual.resolve(self.drop_value.clone());
}
}
impl<T> SingleShotEventual<T>
where
T: Unpin + Clone,
{
pub fn new(drop_value: T) -> Self {
Self {
eventual: EventualValueClone::new(),
drop_value: drop_value,
}
}
// Can only call this once, it consumes the eventual
pub fn resolve(self, value: T) -> EventualResolvedFuture<EventualValueClone<T>> {
self.eventual.resolve(value)
}
pub fn instance(&self) -> EventualValueCloneFuture<T> {
self.eventual.instance()
}
}