mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 14:26:04 +00:00
copy a check from bevy and don't busywait
This commit is contained in:
parent
c315dfd5a1
commit
1df883fdea
1 changed files with 15 additions and 9 deletions
|
@ -4,6 +4,7 @@ use std::{
|
||||||
io,
|
io,
|
||||||
net::SocketAddr,
|
net::SocketAddr,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
|
thread,
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -39,12 +40,11 @@ use azalea_protocol::{
|
||||||
resolver,
|
resolver,
|
||||||
};
|
};
|
||||||
use azalea_world::{Instance, InstanceContainer, InstanceName, PartialInstance};
|
use azalea_world::{Instance, InstanceContainer, InstanceName, PartialInstance};
|
||||||
use bevy_app::{App, AppExit, Plugin, PluginGroup, PluginGroupBuilder, PluginsState, Update};
|
use bevy_app::{App, Plugin, PluginGroup, PluginGroupBuilder, PluginsState, Update};
|
||||||
use bevy_ecs::{
|
use bevy_ecs::{
|
||||||
bundle::Bundle,
|
bundle::Bundle,
|
||||||
component::Component,
|
component::Component,
|
||||||
entity::Entity,
|
entity::Entity,
|
||||||
event::Events,
|
|
||||||
schedule::{InternedScheduleLabel, IntoSystemConfigs, LogLevel, ScheduleBuildSettings},
|
schedule::{InternedScheduleLabel, IntoSystemConfigs, LogLevel, ScheduleBuildSettings},
|
||||||
system::{ResMut, Resource},
|
system::{ResMut, Resource},
|
||||||
world::World,
|
world::World,
|
||||||
|
@ -864,14 +864,20 @@ pub fn start_ecs_runner(
|
||||||
run_schedule_receiver: mpsc::Receiver<()>,
|
run_schedule_receiver: mpsc::Receiver<()>,
|
||||||
run_schedule_sender: mpsc::Sender<()>,
|
run_schedule_sender: mpsc::Sender<()>,
|
||||||
) -> Arc<Mutex<World>> {
|
) -> Arc<Mutex<World>> {
|
||||||
|
// this block is based on Bevy's default runner:
|
||||||
|
// https://github.com/bevyengine/bevy/blob/390877cdae7a17095a75c8f9f1b4241fe5047e83/crates/bevy_app/src/schedule_runner.rs#L77-L85
|
||||||
|
if app.plugins_state() != PluginsState::Cleaned {
|
||||||
// Wait for plugins to load
|
// Wait for plugins to load
|
||||||
if app.plugins_state() == PluginsState::Adding {
|
if app.plugins_state() == PluginsState::Adding {
|
||||||
info!("Waiting for plugins to load ...");
|
info!("Waiting for plugins to load ...");
|
||||||
while matches!(app.plugins_state(), PluginsState::Adding) {}
|
while app.plugins_state() == PluginsState::Adding {
|
||||||
|
thread::yield_now();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Finish adding plugins and cleanup
|
// Finish adding plugins and cleanup
|
||||||
app.finish();
|
app.finish();
|
||||||
app.cleanup();
|
app.cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
// all resources should have been added by now so we can take the ecs from the
|
// all resources should have been added by now so we can take the ecs from the
|
||||||
// app
|
// app
|
||||||
|
|
Loading…
Add table
Reference in a new issue