wip: feeling goodish about scheduler
This commit is contained in:
1 parent
bcaa76a37f
commit
5f63eda294
2 files changed
+53
-36
No files matched your search
@@ -55,6 +55,10 @@ impl<'bump> DiffStack<'bump> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_empty(&self) -> bool {
|
||||||
|
self.instructions.is_empty()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn pop(&mut self) -> Option<DiffInstruction<'bump>> {
|
pub fn pop(&mut self) -> Option<DiffInstruction<'bump>> {
|
||||||
self.instructions.pop()
|
self.instructions.pop()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -531,49 +531,60 @@ impl Scheduler {
|
|||||||
|
|
||||||
use futures_util::future::{select, Either};
|
use futures_util::future::{select, Either};
|
||||||
|
|
||||||
|
// We have to split away some parts of ourself - current lane is borrowed mutably
|
||||||
|
|
||||||
|
let shared = SharedVdom {
|
||||||
|
channel: self.channel.clone(),
|
||||||
|
components: unsafe { &mut *self.components.get() },
|
||||||
|
elements: &mut self.raw_elements,
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut state = current_lane.saved_state.take().unwrap();
|
||||||
|
let mut machine = unsafe { state.promote(shared) };
|
||||||
|
|
||||||
|
if machine.stack.is_empty() {
|
||||||
|
// if let Some(scope) = current_lane.dirty_scopes.pop() {
|
||||||
|
// let component = self.components.get_mut().get_mut(scope.0).unwrap();
|
||||||
|
// let (old, new) = (component.frames.wip_head(), component.frames.fin_head());
|
||||||
|
// machine.stack.push(DiffInstruction::DiffNode { new, old });
|
||||||
|
// } else {
|
||||||
|
// }
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
|
||||||
// if let Some(state) = current_lane.saved_state.take() {
|
// if let Some(state) = current_lane.saved_state.take() {
|
||||||
// let mut machine = unsafe { state.promote(&self) };
|
// let mut machine = unsafe { state.promote(&self) };
|
||||||
// machine.work().await;
|
// machine.work().await;
|
||||||
// } else {
|
// } else {
|
||||||
if let Some(scope) = current_lane.dirty_scopes.pop() {
|
// if let Some(scope) = current_lane.dirty_scopes.pop() {
|
||||||
let (mut saved_work, work_complete): (SavedDiffWork<'static>, bool) = {
|
//
|
||||||
let shared = SharedVdom {
|
|
||||||
channel: self.channel.clone(),
|
|
||||||
components: unsafe { &mut *self.components.get() },
|
|
||||||
elements: &mut self.raw_elements,
|
|
||||||
};
|
|
||||||
let mut machine = DiffMachine::new(Mutations::new(), shared);
|
|
||||||
|
|
||||||
let work_complete = {
|
// let work_complete = {
|
||||||
let fut = machine.diff_scope(scope);
|
// let fut = machine.diff_scope(scope);
|
||||||
pin_mut!(fut);
|
// pin_mut!(fut);
|
||||||
match select(fut, &mut deadline).await {
|
// match select(fut, &mut deadline).await {
|
||||||
Either::Left((work, _other)) => {
|
// Either::Left((work, _other)) => {
|
||||||
//
|
// //
|
||||||
true
|
// true
|
||||||
}
|
// }
|
||||||
Either::Right((deadline, _other)) => {
|
// Either::Right((deadline, _other)) => {
|
||||||
//
|
// //
|
||||||
false
|
// false
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
|
|
||||||
let saved = machine.save();
|
// let mut saved = unsafe { machine.save().extend() };
|
||||||
let extended: SavedDiffWork<'static> = unsafe { transmute(saved) };
|
|
||||||
(extended, work_complete)
|
|
||||||
};
|
|
||||||
|
|
||||||
// release the stack borrow of ourself
|
// // release the stack borrow of ourself
|
||||||
|
// if work_complete {
|
||||||
if work_complete {
|
// for scope in saved.seen_scopes.drain() {
|
||||||
for scope in saved_work.seen_scopes.drain() {
|
// current_lane.dirty_scopes.remove(&scope);
|
||||||
current_lane.dirty_scopes.remove(&scope);
|
// }
|
||||||
}
|
// } else {
|
||||||
} else {
|
// }
|
||||||
}
|
// }
|
||||||
// }
|
// };
|
||||||
};
|
|
||||||
|
|
||||||
// let mut new_mutations = Mutations::new();
|
// let mut new_mutations = Mutations::new();
|
||||||
// match self.work_with_deadline(&mut deadline).await {
|
// match self.work_with_deadline(&mut deadline).await {
|
||||||
@@ -679,6 +690,7 @@ impl Scheduler {
|
|||||||
pub struct PriortySystem {
|
pub struct PriortySystem {
|
||||||
pub dirty_scopes: IndexSet<ScopeId>,
|
pub dirty_scopes: IndexSet<ScopeId>,
|
||||||
pub saved_state: Option<SavedDiffWork<'static>>,
|
pub saved_state: Option<SavedDiffWork<'static>>,
|
||||||
|
pub in_progress: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PriortySystem {
|
impl PriortySystem {
|
||||||
@@ -686,6 +698,7 @@ impl PriortySystem {
|
|||||||
Self {
|
Self {
|
||||||
saved_state: None,
|
saved_state: None,
|
||||||
dirty_scopes: Default::default(),
|
dirty_scopes: Default::default(),
|
||||||
|
in_progress: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user