Fix an apparent race in pipes.
Also removed some unsafety in pipes and added vec::consume_mut.
This commit is contained in:
@@ -6,7 +6,7 @@ import libc::size_t;
|
||||
|
||||
export append;
|
||||
export append_one;
|
||||
export consume;
|
||||
export consume, consume_mut;
|
||||
export init_op;
|
||||
export is_empty;
|
||||
export is_not_empty;
|
||||
@@ -490,6 +490,17 @@ fn consume<T>(+v: ~[T], f: fn(uint, +T)) unsafe {
|
||||
unsafe::set_len(v, 0);
|
||||
}
|
||||
|
||||
fn consume_mut<T>(+v: ~[mut T], f: fn(uint, +T)) unsafe {
|
||||
do as_buf(v) |p, ln| {
|
||||
for uint::range(0, ln) |i| {
|
||||
let x <- *ptr::offset(p, i);
|
||||
f(i, x);
|
||||
}
|
||||
}
|
||||
|
||||
unsafe::set_len(v, 0);
|
||||
}
|
||||
|
||||
/// Remove the last element from a vector and return it
|
||||
fn pop<T>(&v: ~[const T]) -> T {
|
||||
let ln = len(v);
|
||||
|
||||
Reference in New Issue
Block a user