File tree 2 files changed +14
-1
lines changed
2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change 4
4
mod name;
5
5
mod task_pool_options;
6
6
7
+ use bevy_ecs:: schedule:: IntoSystemDescriptor ;
7
8
use bevy_ecs:: system:: Resource ;
9
+ use bevy_ecs:: world:: World ;
8
10
pub use bytemuck:: { bytes_of, cast_slice, Pod , Zeroable } ;
9
11
pub use name:: * ;
10
12
pub use task_pool_options:: * ;
@@ -17,6 +19,7 @@ pub mod prelude {
17
19
18
20
use bevy_app:: prelude:: * ;
19
21
use bevy_ecs:: entity:: Entity ;
22
+ use bevy_tasks:: prelude:: tick_global_task_pools_on_main_thread;
20
23
use bevy_utils:: { Duration , HashSet , Instant } ;
21
24
use std:: borrow:: Cow ;
22
25
use std:: ops:: Range ;
@@ -34,6 +37,13 @@ impl Plugin for CorePlugin {
34
37
. unwrap_or_default ( )
35
38
. create_default_pools ( ) ;
36
39
40
+ // run function in an exclusive system to make sure it runs on main thread
41
+ fn tick_local_executors ( _world : & mut World ) {
42
+ tick_global_task_pools_on_main_thread ( ) ;
43
+ }
44
+
45
+ app. add_system_to_stage ( bevy_app:: CoreStage :: Last , tick. at_end ( ) ) ;
46
+
37
47
app. register_type :: < Entity > ( ) . register_type :: < Name > ( ) ;
38
48
39
49
register_rust_types ( app) ;
Original file line number Diff line number Diff line change @@ -29,7 +29,10 @@ pub mod prelude {
29
29
pub use crate :: {
30
30
iter:: ParallelIterator ,
31
31
slice:: { ParallelSlice , ParallelSliceMut } ,
32
- usages:: { AsyncComputeTaskPool , ComputeTaskPool , IoTaskPool } ,
32
+ usages:: {
33
+ tick_global_task_pools_on_main_thread, AsyncComputeTaskPool , ComputeTaskPool ,
34
+ IoTaskPool ,
35
+ } ,
33
36
} ;
34
37
}
35
38
You can’t perform that action at this time.
0 commit comments