chore: use std::future::Future instead

This commit is contained in:
Jonathan Kelley committed 2022-11-09 11:02:52 -08:00
1 parent f5bc137f01
commit f7df6a9893
10 files changed
+26 -54

No files matched your search

+8 -23
View File
@@ -1,30 +1,15 @@
use std::{
cell::{RefCell, UnsafeCell},
marker::PhantomData,
mem::{self, MaybeUninit},
ops::DerefMut,
pin::Pin,
process::Output,
rc::Rc,
sync::Arc,
task::Poll,
};
use futures_util::{pin_mut, Future, FutureExt};
use slab::Slab;
use std::task::{Context, RawWaker, RawWakerVTable, Waker};
use crate::{Element, ScopeId};
use super::{waker::RcWake, HandleInner, Scheduler, SchedulerMsg};
use super::{waker::RcWake, Scheduler, SchedulerMsg};
use crate::ScopeId;
use std::future::Future;
use std::task::Context;
use std::{cell::UnsafeCell, pin::Pin, rc::Rc, task::Poll};
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
pub struct TaskId(pub usize);
/// the task itself is the waker
pub struct LocalTask {
pub(crate) struct LocalTask {
pub id: TaskId,
pub scope: ScopeId,
pub tx: futures_channel::mpsc::UnboundedSender<SchedulerMsg>,
@@ -41,14 +26,14 @@ impl LocalTask {
// safety: the waker owns its task and everythig is single threaded
let fut = unsafe { &mut *self.task.get() };
match fut.poll_unpin(&mut cx) {
match Pin::new(fut).poll(&mut cx) {
Poll::Ready(_) => true,
_ => false,
}
}
}
impl HandleInner {
impl Scheduler {
pub fn spawn(&self, scope: ScopeId, task: impl Future<Output = ()> + 'static) -> TaskId {
let mut tasks = self.tasks.borrow_mut();
let entry = tasks.vacant_entry();