Created
May 23, 2012 19:06
-
-
Save eholk/2777126 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| resource arc_destruct<T>(data: swappable<~arc_data<T>>) { | |
| let data = unwrap(data); | |
| let ptr = ptr::mut_addr_of((*data).count); | |
| let new_count = rustrt::rust_atomic_decrement(ptr); | |
| assert new_count >= 0; | |
| if new_count > 0 { | |
| unsafe { | |
| unsafe::forget(data); | |
| } | |
| } | |
| // Otherwise, we are the last one, so we use the normal | |
| // shutdown proccess. | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To create the resource: