@@ -1006,15 +1006,13 @@ impl KVStoreSync for TestStore {
10061006
10071007// A `Future` that returns the result only on the second poll.
10081008pub ( crate ) struct TestStoreFuture < R > {
1009- res : Mutex < Option < io:: Result < R > > > ,
1010- first_poll : AtomicBool ,
1009+ inner : Mutex < ( bool , Option < io:: Result < R > > ) > ,
10111010}
10121011
10131012impl < R > TestStoreFuture < R > {
10141013 fn new ( res : io:: Result < R > ) -> Self {
1015- let res = Mutex :: new ( Some ( res) ) ;
1016- let first_poll = AtomicBool :: new ( true ) ;
1017- Self { res, first_poll }
1014+ let inner = Mutex :: new ( ( true , Some ( res) ) ) ;
1015+ Self { inner }
10181016 }
10191017}
10201018
@@ -1023,10 +1021,13 @@ impl<R> Future for TestStoreFuture<R> {
10231021 fn poll (
10241022 self : Pin < & mut Self > , _cx : & mut core:: task:: Context < ' _ > ,
10251023 ) -> core:: task:: Poll < Self :: Output > {
1026- if self . first_poll . swap ( false , Ordering :: Relaxed ) {
1024+ let mut inner_lock = self . inner . lock ( ) . unwrap ( ) ;
1025+ let first_poll = & mut inner_lock. 0 ;
1026+ if * first_poll {
1027+ * first_poll = false ;
10271028 core:: task:: Poll :: Pending
10281029 } else {
1029- if let Some ( res) = self . res . lock ( ) . unwrap ( ) . take ( ) {
1030+ if let Some ( res) = inner_lock . 1 . take ( ) {
10301031 core:: task:: Poll :: Ready ( res)
10311032 } else {
10321033 unreachable ! ( "We should never poll more than twice" ) ;
0 commit comments