@@ -487,7 +487,7 @@ mod tests {
487487 use crate :: { ffi, gil, AsPyPointer , IntoPyPointer , PyObject , Python , ToPyObject } ;
488488 #[ cfg( not( target_arch = "wasm32" ) ) ]
489489 use parking_lot:: { const_mutex, Condvar , Mutex } ;
490- use std:: { ptr:: NonNull , sync :: atomic :: Ordering } ;
490+ use std:: ptr:: NonNull ;
491491
492492 fn get_object ( py : Python < ' _ > ) -> PyObject {
493493 // Convenience function for getting a single unique object, using `new_pool` so as to leave
@@ -503,8 +503,20 @@ mod tests {
503503 OWNED_OBJECTS . with ( |holder| holder. borrow ( ) . len ( ) )
504504 }
505505
506- fn pool_not_dirty ( ) -> bool {
507- !POOL . dirty . load ( Ordering :: SeqCst )
506+ fn pool_inc_refs_does_not_contain ( obj : & PyObject ) -> bool {
507+ !POOL
508+ . pointer_ops
509+ . lock ( )
510+ . 0
511+ . contains ( & unsafe { NonNull :: new_unchecked ( obj. as_ptr ( ) ) } )
512+ }
513+
514+ fn pool_dec_refs_does_not_contain ( obj : & PyObject ) -> bool {
515+ !POOL
516+ . pointer_ops
517+ . lock ( )
518+ . 1
519+ . contains ( & unsafe { NonNull :: new_unchecked ( obj. as_ptr ( ) ) } )
508520 }
509521
510522 #[ cfg( not( target_arch = "wasm32" ) ) ]
@@ -582,13 +594,13 @@ mod tests {
582594 let reference = obj. clone_ref ( py) ;
583595
584596 assert_eq ! ( obj. get_refcnt( py) , 2 ) ;
585- assert ! ( pool_not_dirty ( ) ) ;
597+ assert ! ( pool_inc_refs_does_not_contain ( & obj ) ) ;
586598
587599 // With the GIL held, reference cound will be decreased immediately.
588600 drop ( reference) ;
589601
590602 assert_eq ! ( obj. get_refcnt( py) , 1 ) ;
591- assert ! ( pool_not_dirty ( ) ) ;
603+ assert ! ( pool_dec_refs_does_not_contain ( & obj ) ) ;
592604 } ) ;
593605 }
594606
@@ -601,7 +613,7 @@ mod tests {
601613 let reference = obj. clone_ref ( py) ;
602614
603615 assert_eq ! ( obj. get_refcnt( py) , 2 ) ;
604- assert ! ( pool_not_dirty ( ) ) ;
616+ assert ! ( pool_inc_refs_does_not_contain ( & obj ) ) ;
605617
606618 // Drop reference in a separate thread which doesn't have the GIL.
607619 std:: thread:: spawn ( move || drop ( reference) ) . join ( ) . unwrap ( ) ;
0 commit comments