File tree 2 files changed +4
-6
lines changed
2 files changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -163,10 +163,9 @@ impl<T: Send> BufferPool<T> {
163
163
164
164
fn free ( & mut self , buf : ~Buffer < T > ) {
165
165
unsafe {
166
- use cell:: Cell ;
167
- let buf = Cell :: new ( buf) ;
166
+ let mut buf = Some ( buf) ;
168
167
self . pool . with ( |pool| {
169
- let buf = buf. take ( ) ;
168
+ let buf = buf. take_unwrap ( ) ;
170
169
match pool. iter ( ) . position ( |v| v. size ( ) > buf. size ( ) ) {
171
170
Some ( i) => pool. insert ( i, buf) ,
172
171
None => pool. push ( buf) ,
Original file line number Diff line number Diff line change @@ -19,7 +19,6 @@ use prelude::*;
19
19
20
20
use borrow;
21
21
use cast:: transmute;
22
- use cell:: Cell ;
23
22
use cleanup;
24
23
use libc:: { c_void, uintptr_t, c_char, size_t} ;
25
24
use local_data;
@@ -427,7 +426,6 @@ impl Coroutine {
427
426
}
428
427
429
428
fn build_start_wrapper ( start : proc ( ) ) -> proc ( ) {
430
- let start_cell = Cell :: new ( start) ;
431
429
let wrapper: proc ( ) = proc ( ) {
432
430
// First code after swap to this new context. Run our
433
431
// cleanup job.
@@ -446,6 +444,7 @@ impl Coroutine {
446
444
// need to unsafe_borrow.
447
445
let task: * mut Task = Local :: unsafe_borrow ( ) ;
448
446
447
+ let mut start_cell = Some ( start) ;
449
448
( * task) . run ( || {
450
449
// N.B. Removing `start` from the start wrapper
451
450
// closure by emptying a cell is critical for
@@ -457,7 +456,7 @@ impl Coroutine {
457
456
// be in task context. By moving `start` out of
458
457
// the closure, all the user code goes our of
459
458
// scope while the task is still running.
460
- let start = start_cell. take ( ) ;
459
+ let start = start_cell. take_unwrap ( ) ;
461
460
start ( ) ;
462
461
} ) ;
463
462
}
You can’t perform that action at this time.
0 commit comments