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(); + }); }