From 39e7c3ef95bd957ee4af1a344eaff6c86c47407b Mon Sep 17 00:00:00 2001 From: Sebastian Speitel Date: Fri, 26 Jan 2024 13:36:43 +0100 Subject: [PATCH] fix: use own TaskPool --- src/lib.rs | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index aa64a42..3e3ad0d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -159,9 +159,11 @@ struct Connecting(Arc>) { - let pool = AsyncComputeTaskPool::get_or_init(Default::default); - +fn connect( + mut commands: Commands, + chats: Query<(Entity, &Connection), Added>, + pool: NonSend, +) { for (chat, con) in &chats { let cell = Arc::new(Mutex::new(None)); let config = Config { @@ -171,11 +173,12 @@ fn connect(mut commands: Commands, chats: Query<(Entity, &Connection), Added(); + app.add_systems(PreUpdate, tick); app.add_event::(); app.add_systems(Update, connect); @@ -334,8 +337,11 @@ impl bevy_app::Plugin for IRCPlugin { } } -#[derive(Resource)] -struct NonSendRes; -fn main_thread_system(_: NonSend) { - bevy_tasks::tick_global_task_pools_on_main_thread(); +#[derive(Resource, Default)] +struct TaskPool(bevy_tasks::TaskPool); + +fn tick(pool: NonSend) { + pool.0.with_local_executor(|executor| { + executor.try_tick(); + }); }