diff options
| author | bors <bors@rust-lang.org> | 2013-08-13 04:59:20 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-08-13 04:59:20 -0700 |
| commit | f02cc6bf0a276115a31354b1c1530e6fe9eb4d58 (patch) | |
| tree | f5b4895221d2354eae0a71cdf1cb99eb50bac693 /src/libstd/unstable | |
| parent | c99b2b932f1da9b1746387d8968476240dadf204 (diff) | |
| parent | 5ac8c57bd420d61ed80a07746ab1a75e4062383f (diff) | |
auto merge of #8411 : bblum/rust/assorted-fixes, r=brson
Each commit is pretty much what it says on the tin. r anybody.
Diffstat (limited to 'src/libstd/unstable')
| -rw-r--r-- | src/libstd/unstable/sync.rs | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/src/libstd/unstable/sync.rs b/src/libstd/unstable/sync.rs index a9dded41683..adbf9fc7578 100644 --- a/src/libstd/unstable/sync.rs +++ b/src/libstd/unstable/sync.rs @@ -229,20 +229,22 @@ impl<T> Drop for UnsafeAtomicRcBox<T>{ if self.data.is_null() { return; // Happens when destructing an unwrapper's handle. } - do task::unkillable { - let mut data: ~AtomicRcBoxData<T> = cast::transmute(self.data); - // Must be acquire+release, not just release, to make sure this - // doesn't get reordered to after the unwrapper pointer load. - let old_count = data.count.fetch_sub(1, SeqCst); - assert!(old_count >= 1); - if old_count == 1 { - // Were we really last, or should we hand off to an - // unwrapper? It's safe to not xchg because the unwrapper - // will set the unwrap lock *before* dropping his/her - // reference. In effect, being here means we're the only - // *awake* task with the data. - match data.unwrapper.take(Acquire) { - Some(~(message,response)) => { + let mut data: ~AtomicRcBoxData<T> = cast::transmute(self.data); + // Must be acquire+release, not just release, to make sure this + // doesn't get reordered to after the unwrapper pointer load. + let old_count = data.count.fetch_sub(1, SeqCst); + assert!(old_count >= 1); + if old_count == 1 { + // Were we really last, or should we hand off to an + // unwrapper? It's safe to not xchg because the unwrapper + // will set the unwrap lock *before* dropping his/her + // reference. In effect, being here means we're the only + // *awake* task with the data. + match data.unwrapper.take(Acquire) { + Some(~(message,response)) => { + let cell = Cell::new((message, response, data)); + do task::unkillable { + let (message, response, data) = cell.take(); // Send 'ready' and wait for a response. message.send(()); // Unkillable wait. Message guaranteed to come. @@ -253,13 +255,13 @@ impl<T> Drop for UnsafeAtomicRcBox<T>{ // Other task was killed. drop glue takes over. } } - None => { - // drop glue takes over. - } } - } else { - cast::forget(data); + None => { + // drop glue takes over. + } } + } else { + cast::forget(data); } } } |
