mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-23 12:43:08 +00:00
wip: more scheduler work
This commit is contained in:
parent
1cd5e69712
commit
44b4384961
4 changed files with 16 additions and 10 deletions
2
packages/core/.vscode/settings.json
vendored
2
packages/core/.vscode/settings.json
vendored
|
@ -1,3 +1,3 @@
|
|||
{
|
||||
"rust-analyzer.inlayHints.enable": true
|
||||
"rust-analyzer.inlayHints.enable": false
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@ impl<'bump> DiffMachine<'bump> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn diff_scope(&'bump mut self, id: ScopeId) {
|
||||
pub fn diff_scope(&mut self, id: ScopeId) {
|
||||
if let Some(component) = self.vdom.get_scope_mut(id) {
|
||||
let (old, new) = (component.frames.wip_head(), component.frames.fin_head());
|
||||
self.stack.push(DiffInstruction::DiffNode { new, old });
|
||||
|
|
|
@ -335,20 +335,20 @@ impl Scheduler {
|
|||
///
|
||||
/// Will use the standard priority-based scheduling, batching, etc, but just won't interact with the async reactor.
|
||||
pub fn work_sync<'a>(&'a mut self) -> Vec<Mutations<'a>> {
|
||||
let mut committed_mutations = Vec::<Mutations<'static>>::new();
|
||||
let mut committed_mutations = Vec::new();
|
||||
|
||||
// Internalize any pending work since the last time we ran
|
||||
self.manually_poll_events();
|
||||
|
||||
if !self.has_any_work() {
|
||||
self.pool.clean_up_garbage();
|
||||
return committed_mutations;
|
||||
}
|
||||
|
||||
while self.has_any_work() {
|
||||
// do work
|
||||
|
||||
// Create work from the pending event queue
|
||||
self.consume_pending_events();
|
||||
|
||||
while self.has_any_work() {
|
||||
self.shift_priorities();
|
||||
self.work_on_current_lane(&mut || false, &mut committed_mutations);
|
||||
}
|
||||
|
||||
committed_mutations
|
||||
|
@ -419,7 +419,9 @@ impl Scheduler {
|
|||
committed_mutations
|
||||
}
|
||||
|
||||
// returns true if the lane is finished
|
||||
/// Load the current lane, and work on it, periodically checking in if the deadline has been reached.
|
||||
///
|
||||
/// Returns true if the lane is finished before the deadline could be met.
|
||||
pub fn work_on_current_lane(
|
||||
&mut self,
|
||||
deadline_reached: &mut impl FnMut() -> bool,
|
||||
|
|
|
@ -228,6 +228,9 @@ impl VirtualDom {
|
|||
unsafe { std::mem::transmute(diff_machine.mutations) }
|
||||
}
|
||||
|
||||
/// Compute a manual diff of the VirtualDOM between states.
|
||||
///
|
||||
/// This can be useful when state inside the DOM is remotely changed from the outside, but not propogated as an event.
|
||||
pub fn diff<'s>(&'s mut self) -> Mutations<'s> {
|
||||
let cur_component = self
|
||||
.scheduler
|
||||
|
@ -236,7 +239,8 @@ impl VirtualDom {
|
|||
.expect("The base scope should never be moved");
|
||||
|
||||
if cur_component.run_scope(&self.scheduler.pool) {
|
||||
let mut diff_machine = DiffMachine::new(Mutations::new(), todo!());
|
||||
let mut diff_machine: DiffMachine<'s> =
|
||||
DiffMachine::new(Mutations::new(), &mut self.scheduler.pool);
|
||||
diff_machine.diff_scope(self.base_scope);
|
||||
diff_machine.mutations
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue