@@ -951,49 +951,6 @@ impl<T /*: ?Sized*/, R: Deref<Target = RwLock<T, G>> + Clone, G: SpinGuardian> D
951951 }
952952}
953953
954- impl <T /*: ?Sized*/ , R : Deref <Target = RwLock <T , G >> + Clone , G : SpinGuardian >
955- RwLockWriteGuard_ <T , R , G >
956- {
957- /// Atomically downgrades a write guard to an upgradeable reader guard.
958- ///
959- /// This method always succeeds because the lock is exclusively held by the writer.
960- #[ verifier:: exec_allows_no_decreases_clause]
961- pub fn downgrade( /* mut */ self ) -> RwLockUpgradeableGuard_ <T , R , G > {
962- let mut this = self ;
963- loop {
964- // self = match self.try_downgrade() {
965- this = match this. try_downgrade( ) {
966- Ok ( guard) => return guard,
967- Err ( e) => e,
968- } ;
969- }
970- }
971-
972- /// This is not exposed as a public method to prevent intermediate lock states from affecting the
973- /// downgrade process.
974- #[ verifier:: external_body]
975- fn try_downgrade( /* mut */ self ) -> Result <RwLockUpgradeableGuard_ <T , R , G >, Self > {
976- let inner = self . inner. clone( ) ;
977- // let res = self
978- // .inner
979- // .lock
980- // .compare_exchange(WRITER, UPGRADEABLE_READER, AcqRel, Relaxed);
981- let res = atomic_with_ghost!(
982- & self . inner. lock => compare_exchange( WRITER , UPGRADEABLE_READER ) ;
983- returning res;
984- ghost g => { }
985- ) ;
986- if res. is_ok( ) {
987- // let guard = self.guard.transfer_to();
988- // drop(self);
989- let this = core:: mem:: ManuallyDrop :: new( self ) ;
990- let guard = unsafe { core:: ptr:: read( & this. guard) } ;
991- Ok ( RwLockUpgradeableGuard_ { inner, guard, v_perm: Tracked :: assume_new( ) } )
992- } else {
993- Err ( self )
994- }
995- }
996- }
997954} // verus!
998955/*
999956impl<T: ?Sized, R: Deref<Target = RwLock<T, G>> + Clone, G: SpinGuardian> DerefMut
0 commit comments