@@ -8,8 +8,11 @@ use masonry::core::DefaultProperties;
88use masonry:: peniko:: { Blob , Color } ;
99use masonry:: theme:: { BACKGROUND_COLOR , default_property_set} ;
1010use masonry_winit:: app:: { EventLoopBuilder , MasonryState , MasonryUserEvent , NewWindow , WindowId } ;
11- use tokio:: runtime:: Runtime as TokioRuntime ;
1211use winit:: error:: EventLoopError ;
12+ use xilem_masonry:: runtime:: Executor ;
13+
14+ #[ cfg( feature = "tokio-rt" ) ]
15+ use tokio:: runtime:: Runtime as TokioRuntime ;
1316
1417use crate :: core:: map_state;
1518use crate :: window_options:: WindowCallbacks ;
@@ -22,7 +25,7 @@ use crate::{MasonryDriver, WidgetView, WindowOptions, WindowView};
2225pub struct Xilem < State , Logic > {
2326 state : State ,
2427 logic : Logic ,
25- runtime : Arc < TokioRuntime > ,
28+ runtime : Arc < Executor > ,
2629 default_properties : Option < DefaultProperties > ,
2730 default_base_color : Color ,
2831 // Font data to include in loading.
@@ -62,21 +65,34 @@ impl<State>
6265 where
6366 View : WidgetView < State > ,
6467 {
65- Self :: new_simple_with_tokio (
66- state,
67- logic,
68- window_options,
69- Arc :: new ( TokioRuntime :: new ( ) . unwrap ( ) ) ,
70- )
68+ Self :: new_simple_with_executor ( state, logic, window_options, Executor :: new ( ) . into ( ) )
7169 }
7270
7371 /// Same as [`Self::new_simple`] but allows passing an existing tokio runtime.
72+ #[ deprecated(
73+ since = "0.4.0" ,
74+ note = "use `Xilem::new_simple_with_executor` with `xilem_masonry::runtime::Executor` instead"
75+ ) ]
76+ #[ cfg( feature = "tokio-rt" ) ]
7477 pub fn new_simple_with_tokio < View > (
7578 state : State ,
76- mut logic : impl FnMut ( & mut State ) -> View + ' static ,
79+ logic : impl FnMut ( & mut State ) -> View + ' static ,
7780 window_options : WindowOptions < State > ,
7881 tokio_rt : Arc < TokioRuntime > ,
7982 ) -> Self
83+ where
84+ View : WidgetView < State > ,
85+ {
86+ Self :: new_simple_with_executor ( state, logic, window_options, Arc :: new ( tokio_rt. into ( ) ) )
87+ }
88+
89+ /// Same as [`Self::new_simple`] but allows passing an existing runtime executor.
90+ pub fn new_simple_with_executor < View > (
91+ state : State ,
92+ mut logic : impl FnMut ( & mut State ) -> View + ' static ,
93+ window_options : WindowOptions < State > ,
94+ runtime : Arc < Executor > ,
95+ ) -> Self
8096 where
8197 View : WidgetView < State > ,
8298 {
@@ -112,7 +128,7 @@ impl<State>
112128 } ) ,
113129 )
114130 } ) ,
115- tokio_rt ,
131+ runtime ,
116132 )
117133 }
118134}
@@ -138,10 +154,10 @@ where
138154 where
139155 State : AppState ,
140156 {
141- Self :: new_inner ( state, logic, Arc :: new ( TokioRuntime :: new ( ) . unwrap ( ) ) )
157+ Self :: new_inner ( state, logic, Arc :: new ( Executor :: new ( ) ) )
142158 }
143159
144- fn new_inner ( state : State , logic : Logic , runtime : Arc < TokioRuntime > ) -> Self {
160+ fn new_inner ( state : State , logic : Logic , runtime : Arc < Executor > ) -> Self {
145161 Self {
146162 state,
147163 logic,
0 commit comments