actually set task
This commit is contained in:
3 files changed
+6
-5
No files matched your search
@@ -89,7 +89,7 @@ impl Runtime {
|
|||||||
/// Drop the future with the given TaskId
|
/// Drop the future with the given TaskId
|
||||||
///
|
///
|
||||||
/// This does not abort the task, so you'll want to wrap it in an abort handle if that's important to you
|
/// This does not abort the task, so you'll want to wrap it in an abort handle if that's important to you
|
||||||
pub fn remove(&self, id: Task) -> Option<LocalTask> {
|
pub(crate) fn remove_task(&self, id: Task) -> Option<LocalTask> {
|
||||||
self.tasks.borrow_mut().try_remove(id.0)
|
self.tasks.borrow_mut().try_remove(id.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ impl VirtualDom {
|
|||||||
// update the scope stack
|
// update the scope stack
|
||||||
self.runtime.scope_stack.borrow_mut().push(task.scope);
|
self.runtime.scope_stack.borrow_mut().push(task.scope);
|
||||||
self.runtime.rendering.set(false);
|
self.runtime.rendering.set(false);
|
||||||
|
self.runtime.current_task.set(Some(id));
|
||||||
|
|
||||||
// If the task completes...
|
// If the task completes...
|
||||||
if task.task.borrow_mut().as_mut().poll(&mut cx).is_ready() {
|
if task.task.borrow_mut().as_mut().poll(&mut cx).is_ready() {
|
||||||
@@ -35,5 +36,6 @@ impl VirtualDom {
|
|||||||
// Remove the scope from the stack
|
// Remove the scope from the stack
|
||||||
self.runtime.scope_stack.borrow_mut().pop();
|
self.runtime.scope_stack.borrow_mut().pop();
|
||||||
self.runtime.rendering.set(true);
|
self.runtime.rendering.set(true);
|
||||||
|
self.runtime.current_task.set(None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,7 +8,6 @@ use std::{
|
|||||||
any::Any,
|
any::Any,
|
||||||
cell::{Cell, RefCell},
|
cell::{Cell, RefCell},
|
||||||
future::Future,
|
future::Future,
|
||||||
rc::Rc,
|
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -250,7 +249,7 @@ impl ScopeContext {
|
|||||||
///
|
///
|
||||||
/// This drops the task immediately.
|
/// This drops the task immediately.
|
||||||
pub fn remove_future(&self, id: Task) {
|
pub fn remove_future(&self, id: Task) {
|
||||||
with_runtime(|rt| rt.remove(id)).expect("Runtime to exist");
|
with_runtime(|rt| rt.remove_task(id)).expect("Runtime to exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Mark this component as suspended and then return None
|
/// Mark this component as suspended and then return None
|
||||||
@@ -314,10 +313,10 @@ impl ScopeContext {
|
|||||||
|
|
||||||
impl Drop for ScopeContext {
|
impl Drop for ScopeContext {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
|
// Drop all spawned tasks
|
||||||
with_runtime(|rt| {
|
with_runtime(|rt| {
|
||||||
// Drop all spawned tasks
|
|
||||||
for id in self.spawned_tasks.borrow().iter() {
|
for id in self.spawned_tasks.borrow().iter() {
|
||||||
rt.remove(*id);
|
rt.remove_task(*id);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.expect("Runtime to exist")
|
.expect("Runtime to exist")
|
||||||
|
|||||||
Reference in new issue
Block a user