This commit is contained in:
Antonio Scandurra 2023-10-21 17:52:47 +02:00
parent e4fe9538d7
commit b7d30fca2b
30 changed files with 3644 additions and 29 deletions

View file

@ -1,10 +1,12 @@
use crate::PlatformDispatcher;
use crate::{AppContext, PlatformDispatcher};
use smol::prelude::*;
use std::{
fmt::Debug,
pin::Pin,
sync::Arc,
task::{Context, Poll},
};
use util::TryFutureExt;
#[derive(Clone)]
pub struct Executor {
@ -30,6 +32,16 @@ impl<T> Task<T> {
}
}
impl<E, T> Task<Result<T, E>>
where
T: 'static + Send,
E: 'static + Send + Debug,
{
pub fn detach_and_log_err(self, cx: &mut AppContext) {
cx.executor().spawn(self.log_err()).detach();
}
}
impl<T> Future for Task<T> {
type Output = T;