@@ -28,6 +28,7 @@ use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
2828use std:: sync:: { Arc , Mutex , RwLock } ;
2929use std:: task:: { Poll , Waker } ;
3030
31+ use async_lock:: OnceCell ;
3132use async_task:: Runnable ;
3233use concurrent_queue:: ConcurrentQueue ;
3334use futures_lite:: { future, prelude:: * } ;
@@ -63,7 +64,7 @@ pub use async_task::Task;
6364#[ derive( Debug ) ]
6465pub struct Executor < ' a > {
6566 /// The executor state.
66- state : once_cell :: sync :: OnceCell < Arc < State > > ,
67+ state : OnceCell < Arc < State > > ,
6768
6869 /// Makes the `'a` lifetime invariant.
6970 _marker : PhantomData < std:: cell:: UnsafeCell < & ' a ( ) > > ,
@@ -87,7 +88,7 @@ impl<'a> Executor<'a> {
8788 /// ```
8889 pub const fn new ( ) -> Executor < ' a > {
8990 Executor {
90- state : once_cell :: sync :: OnceCell :: new ( ) ,
91+ state : OnceCell :: new ( ) ,
9192 _marker : PhantomData ,
9293 }
9394 }
@@ -249,7 +250,7 @@ impl<'a> Executor<'a> {
249250
250251 /// Returns a reference to the inner state.
251252 fn state ( & self ) -> & Arc < State > {
252- self . state . get_or_init ( || Arc :: new ( State :: new ( ) ) )
253+ self . state . get_or_init_blocking ( || Arc :: new ( State :: new ( ) ) )
253254 }
254255}
255256
@@ -292,7 +293,7 @@ impl<'a> Default for Executor<'a> {
292293#[ derive( Debug ) ]
293294pub struct LocalExecutor < ' a > {
294295 /// The inner executor.
295- inner : once_cell :: unsync :: OnceCell < Executor < ' a > > ,
296+ inner : Executor < ' a > ,
296297
297298 /// Makes the type `!Send` and `!Sync`.
298299 _marker : PhantomData < Rc < ( ) > > ,
@@ -313,7 +314,7 @@ impl<'a> LocalExecutor<'a> {
313314 /// ```
314315 pub const fn new ( ) -> LocalExecutor < ' a > {
315316 LocalExecutor {
316- inner : once_cell :: unsync :: OnceCell :: new ( ) ,
317+ inner : Executor :: new ( ) ,
317318 _marker : PhantomData ,
318319 }
319320 }
@@ -447,7 +448,7 @@ impl<'a> LocalExecutor<'a> {
447448
448449 /// Returns a reference to the inner executor.
449450 fn inner ( & self ) -> & Executor < ' a > {
450- self . inner . get_or_init ( Executor :: new )
451+ & self . inner
451452 }
452453}
453454
0 commit comments