File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -218,6 +218,21 @@ where
218
218
& mut * ptr:: addr_of_mut!( ( * this. node_ptr. as_ptr( ) . cast:: <ArcInner <P :: Data >>( ) ) . data)
219
219
}
220
220
221
+ /// Returns the number of strong (`Arc`) pointers to this allocation
222
+ pub fn strong_count ( this : & Self ) -> usize {
223
+ this. inner ( ) . strong . load ( Ordering :: SeqCst )
224
+ }
225
+
226
+ /// Returns a mutable reference to the inner data if there are no other `Arc` pointers to the
227
+ pub fn get_mut ( this : & mut Self ) -> Option < & mut P :: Data > {
228
+ if Self :: strong_count ( this) == 1 {
229
+ // SAFETY: we just checked that the strong count is 1
230
+ Some ( unsafe { Self :: get_mut_unchecked ( this) } )
231
+ } else {
232
+ None
233
+ }
234
+ }
235
+
221
236
#[ inline( never) ]
222
237
unsafe fn drop_slow ( & mut self ) {
223
238
// run `P::Data`'s destructor
You can’t perform that action at this time.
0 commit comments