|
|
|
@ -55,7 +55,7 @@ machines) incrementing the reference count at once. This is what we'll do.
|
|
|
|
|
|
|
|
|
|
It's pretty simple to implement this behaviour:
|
|
|
|
|
```rust,ignore
|
|
|
|
|
if old_rc >= isize::MAX {
|
|
|
|
|
if old_rc >= isize::MAX as usize {
|
|
|
|
|
std::process::abort();
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
@ -77,9 +77,9 @@ impl<T> Clone for Arc<T> {
|
|
|
|
|
let inner = unsafe { self.ptr.as_ref() };
|
|
|
|
|
// Using a relaxed ordering is alright here as knowledge of the original
|
|
|
|
|
// reference prevents other threads from wrongly deleting the object.
|
|
|
|
|
inner.rc.fetch_add(1, Ordering::Relaxed);
|
|
|
|
|
let old_rc = inner.rc.fetch_add(1, Ordering::Relaxed);
|
|
|
|
|
|
|
|
|
|
if old_rc >= isize::MAX {
|
|
|
|
|
if old_rc >= isize::MAX as usize {
|
|
|
|
|
std::process::abort();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|