Skip to content

Commit

Permalink
remove send-ness from scheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
maniwani committed Jul 12, 2023
1 parent 7c3131a commit 7c70fc1
Showing 1 changed file with 3 additions and 23 deletions.
26 changes: 3 additions & 23 deletions crates/bevy_ecs/src/schedule/executor/multi_threaded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ struct SystemTaskMetadata {
archetype_component_access: Access<ArchetypeComponentId>,
/// Indices of the systems that directly depend on the system.
dependents: Vec<usize>,
/// Is `true` if the system does not access `!Send` data.
is_send: bool,
/// Is `true` if the system is exclusive.
is_exclusive: bool,
}
Expand All @@ -80,8 +78,6 @@ pub struct MultiThreadedExecutor {
system_task_metadata: Vec<SystemTaskMetadata>,
/// Union of the accesses of all currently running systems.
active_access: Access<ArchetypeComponentId>,
/// Returns `true` if a system with non-`Send` access is running.
local_thread_running: bool,
/// Returns `true` if an exclusive system is running.
exclusive_running: bool,
/// The number of systems expected to run.
Expand Down Expand Up @@ -151,7 +147,6 @@ impl SystemExecutor for MultiThreadedExecutor {
self.system_task_metadata.push(SystemTaskMetadata {
archetype_component_access: default(),
dependents: schedule.system_dependents[index].clone(),
is_send: schedule.systems[index].is_send(),
is_exclusive: schedule.systems[index].is_exclusive(),
});
}
Expand Down Expand Up @@ -270,7 +265,6 @@ impl MultiThreadedExecutor {
num_completed_systems: 0,
num_dependencies_remaining: Vec::new(),
active_access: default(),
local_thread_running: false,
exclusive_running: false,
evaluated_sets: FixedBitSet::new(),
ready_systems: FixedBitSet::new(),
Expand Down Expand Up @@ -370,10 +364,6 @@ impl MultiThreadedExecutor {
return false;
}

if !system_meta.is_send && self.local_thread_running {
return false;
}

// TODO: an earlier out if world's archetypes did not change
for set_idx in conditions.sets_with_conditions_of_systems[system_index]
.difference(&self.evaluated_sets)
Expand Down Expand Up @@ -530,12 +520,7 @@ impl MultiThreadedExecutor {
self.active_access
.extend(&system_meta.archetype_component_access);

if system_meta.is_send {
scope.spawn(task);
} else {
self.local_thread_running = true;
scope.spawn_on_external(task);
}
scope.spawn(task);
}

/// # Safety
Expand Down Expand Up @@ -583,7 +568,7 @@ impl MultiThreadedExecutor {

#[cfg(feature = "trace")]
let task = task.instrument(task_span);
scope.spawn_on_scope(task);
scope.spawn(task);
} else {
let task = async move {
#[cfg(feature = "trace")]
Expand Down Expand Up @@ -613,11 +598,10 @@ impl MultiThreadedExecutor {

#[cfg(feature = "trace")]
let task = task.instrument(task_span);
scope.spawn_on_scope(task);
scope.spawn(task);
}

self.exclusive_running = true;
self.local_thread_running = true;
}

fn finish_system_and_handle_dependents(&mut self, result: SystemResult) {
Expand All @@ -630,10 +614,6 @@ impl MultiThreadedExecutor {
self.exclusive_running = false;
}

if !self.system_task_metadata[system_index].is_send {
self.local_thread_running = false;
}

debug_assert!(self.num_running_systems >= 1);
self.num_running_systems -= 1;
self.num_completed_systems += 1;
Expand Down

0 comments on commit 7c70fc1

Please sign in to comment.