@@ -229,20 +229,22 @@ impl<T> Drop for UnsafeAtomicRcBox<T>{
229
229
if self . data . is_null ( ) {
230
230
return ; // Happens when destructing an unwrapper's handle.
231
231
}
232
- do task:: unkillable {
233
- let mut data : ~AtomicRcBoxData <T > = cast:: transmute ( self . data ) ;
234
- // Must be acquire+release, not just release, to make sure this
235
- // doesn't get reordered to after the unwrapper pointer load.
236
- let old_count = data. count . fetch_sub ( 1 , SeqCst ) ;
237
- assert ! ( old_count >= 1 ) ;
238
- if old_count == 1 {
239
- // Were we really last, or should we hand off to an
240
- // unwrapper? It's safe to not xchg because the unwrapper
241
- // will set the unwrap lock *before* dropping his/her
242
- // reference. In effect, being here means we're the only
243
- // *awake* task with the data.
244
- match data. unwrapper . take ( Acquire ) {
245
- Some ( ~( message, response) ) => {
232
+ let mut data: ~AtomicRcBoxData < T > = cast:: transmute ( self . data ) ;
233
+ // Must be acquire+release, not just release, to make sure this
234
+ // doesn't get reordered to after the unwrapper pointer load.
235
+ let old_count = data. count . fetch_sub ( 1 , SeqCst ) ;
236
+ assert ! ( old_count >= 1 ) ;
237
+ if old_count == 1 {
238
+ // Were we really last, or should we hand off to an
239
+ // unwrapper? It's safe to not xchg because the unwrapper
240
+ // will set the unwrap lock *before* dropping his/her
241
+ // reference. In effect, being here means we're the only
242
+ // *awake* task with the data.
243
+ match data. unwrapper . take ( Acquire ) {
244
+ Some ( ~( message, response) ) => {
245
+ let cell = Cell :: new ( ( message, response, data) ) ;
246
+ do task:: unkillable {
247
+ let ( message, response, data) = cell. take ( ) ;
246
248
// Send 'ready' and wait for a response.
247
249
message. send ( ( ) ) ;
248
250
// Unkillable wait. Message guaranteed to come.
@@ -253,13 +255,13 @@ impl<T> Drop for UnsafeAtomicRcBox<T>{
253
255
// Other task was killed. drop glue takes over.
254
256
}
255
257
}
256
- None => {
257
- // drop glue takes over.
258
- }
259
258
}
260
- } else {
261
- cast:: forget ( data) ;
259
+ None => {
260
+ // drop glue takes over.
261
+ }
262
262
}
263
+ } else {
264
+ cast : : forget ( data) ;
263
265
}
264
266
}
265
267
}
0 commit comments