aboutsummaryrefslogtreecommitdiff
path: root/azalea-client/src
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2025-12-28 04:31:29 -0600
committerGitHub <noreply@github.com>2025-12-28 04:31:29 -0600
commit20c7e27250148f62bab9e7b99e4f0cd6deb82325 (patch)
tree163b312ef4dc72c5c23be923f8ca17cdf2a7278c /azalea-client/src
parent7ab3b8924f64f7eadb6b8928b6fae73cb06e4c2f (diff)
downloadazalea-drasl-20c7e27250148f62bab9e7b99e4f0cd6deb82325.tar.xz
Change Client::component to return a reference (#298)
* change Client::component to return a reference * write docs * merge main * remove unused parking_lot feature
Diffstat (limited to 'azalea-client/src')
-rw-r--r--azalea-client/src/client.rs14
1 files changed, 9 insertions, 5 deletions
diff --git a/azalea-client/src/client.rs b/azalea-client/src/client.rs
index 4c45b537..b7d01d58 100644
--- a/azalea-client/src/client.rs
+++ b/azalea-client/src/client.rs
@@ -18,7 +18,7 @@ use bevy_ecs::{
prelude::*,
schedule::{InternedScheduleLabel, LogLevel, ScheduleBuildSettings},
};
-use parking_lot::Mutex;
+use parking_lot::RwLock;
use tokio::{sync::oneshot, time};
use tracing::{info, warn};
@@ -118,7 +118,11 @@ impl Plugin for AzaleaPlugin {
#[doc(hidden)]
pub fn start_ecs_runner(
app: &mut SubApp,
-) -> (Arc<Mutex<World>>, impl FnOnce(), oneshot::Receiver<AppExit>) {
+) -> (
+ Arc<RwLock<World>>,
+ impl FnOnce(),
+ oneshot::Receiver<AppExit>,
+) {
// 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 {
@@ -136,7 +140,7 @@ pub fn start_ecs_runner(
// all resources should have been added by now so we can take the ecs from the
// app
- let ecs = Arc::new(Mutex::new(mem::take(app.world_mut())));
+ let ecs = Arc::new(RwLock::new(mem::take(app.world_mut())));
let ecs_clone = ecs.clone();
let outer_schedule_label = *app.update_schedule.as_ref().unwrap();
@@ -157,7 +161,7 @@ pub fn start_ecs_runner(
///
/// Exits when we receive an `AppExit` event.
async fn run_schedule_loop(
- ecs: Arc<Mutex<World>>,
+ ecs: Arc<RwLock<World>>,
outer_schedule_label: InternedScheduleLabel,
) -> AppExit {
let mut last_update: Option<Instant> = None;
@@ -181,7 +185,7 @@ async fn run_schedule_loop(
}
last_update = Some(now);
- let mut ecs = ecs.lock();
+ let mut ecs = ecs.write();
// if last tick is None or more than 50ms ago, run the GameTick schedule
ecs.run_schedule(outer_schedule_label);