File tree 2 files changed +5
-7
lines changed
2 files changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ machines) incrementing the reference count at once. This is what we'll do.
55
55
56
56
It's pretty simple to implement this behaviour:
57
57
``` rust,ignore
58
- if old_rc >= isize::MAX {
58
+ if old_rc >= isize::MAX as usize {
59
59
std::process::abort();
60
60
}
61
61
```
@@ -77,9 +77,9 @@ impl<T> Clone for Arc<T> {
77
77
let inner = unsafe { self.ptr.as_ref() };
78
78
// Using a relaxed ordering is alright here as knowledge of the original
79
79
// reference prevents other threads from wrongly deleting the object.
80
- inner.rc.fetch_add(1, Ordering::Relaxed);
80
+ let old_rc = inner.rc.fetch_add(1, Ordering::Relaxed);
81
81
82
- if old_rc >= isize::MAX {
82
+ if old_rc >= isize::MAX as usize {
83
83
std::process::abort();
84
84
}
85
85
Original file line number Diff line number Diff line change @@ -46,16 +46,14 @@ impl<T> Deref for Arc<T> {
46
46
}
47
47
}
48
48
49
- use std :: sync :: atomic :: Ordering ;
50
-
51
49
impl <T > Clone for Arc <T > {
52
50
fn clone (& self ) -> Arc <T > {
53
51
let inner = unsafe { self . ptr. as_ref () };
54
52
// Using a relaxed ordering is alright here as knowledge of the original
55
53
// reference prevents other threads from wrongly deleting the object.
56
- inner . rc. fetch_add (1 , Ordering :: Relaxed );
54
+ let old_rc = inner . rc. fetch_add (1 , Ordering :: Relaxed );
57
55
58
- if old_rc >= isize :: MAX {
56
+ if old_rc >= isize :: MAX as usize {
59
57
std :: process :: abort ();
60
58
}
61
59
You can’t perform that action at this time.
0 commit comments