chore: make clippy happy
This commit is contained in:
1 parent
7c3d308ab5
commit
03aea885cf
12 files changed
+67
-103
No files matched your search
@@ -41,7 +41,7 @@ impl SuspenseBoundary {
|
||||
Self {
|
||||
id,
|
||||
waiting_on: Default::default(),
|
||||
mutations: RefCell::new(Mutations::new()),
|
||||
mutations: RefCell::new(Mutations::default()),
|
||||
placeholder: Cell::new(None),
|
||||
created_on_stack: Cell::new(0),
|
||||
onresolve: None,
|
||||
|
||||
@@ -2,8 +2,7 @@ use super::{waker::RcWake, Scheduler, SchedulerMsg};
|
||||
use crate::ScopeId;
|
||||
use std::cell::RefCell;
|
||||
use std::future::Future;
|
||||
use std::task::Context;
|
||||
use std::{pin::Pin, rc::Rc, task::Poll};
|
||||
use std::{pin::Pin, rc::Rc};
|
||||
|
||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
|
||||
@@ -12,22 +11,9 @@ pub struct TaskId(pub usize);
|
||||
/// the task itself is the waker
|
||||
pub(crate) struct LocalTask {
|
||||
pub scope: ScopeId,
|
||||
pub(super) task: RefCell<Pin<Box<dyn Future<Output = ()> + 'static>>>,
|
||||
id: TaskId,
|
||||
tx: futures_channel::mpsc::UnboundedSender<SchedulerMsg>,
|
||||
task: RefCell<Pin<Box<dyn Future<Output = ()> + 'static>>>,
|
||||
}
|
||||
|
||||
impl LocalTask {
|
||||
/// Poll this task and return whether or not it is complete
|
||||
pub(super) fn progress(self: &Rc<Self>) -> bool {
|
||||
let waker = self.waker();
|
||||
let mut cx = Context::from_waker(&waker);
|
||||
|
||||
match self.task.borrow_mut().as_mut().poll(&mut cx) {
|
||||
Poll::Ready(_) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Scheduler {
|
||||
|
||||
@@ -18,8 +18,11 @@ impl VirtualDom {
|
||||
let mut tasks = self.scheduler.tasks.borrow_mut();
|
||||
let task = &tasks[id.0];
|
||||
|
||||
let waker = task.waker();
|
||||
let mut cx = Context::from_waker(&waker);
|
||||
|
||||
// If the task completes...
|
||||
if task.progress() {
|
||||
if task.task.borrow_mut().as_mut().poll(&mut cx).is_ready() {
|
||||
// Remove it from the scope so we dont try to double drop it when the scope dropes
|
||||
self.scopes[task.scope.0].spawned_tasks.remove(&id);
|
||||
|
||||
|
||||
Reference in new issue
Block a user