Use less move_it in pipes and future (all but one use)
This commit is contained in:
parent
6cf2f89452
commit
8d00603d78
@ -64,17 +64,13 @@ fn from_value<A>(+val: A) -> Future<A> {
|
||||
})
|
||||
}
|
||||
|
||||
macro_rules! move_it (
|
||||
($x:expr) => { unsafe { let y <- *ptr::addr_of($x); y } }
|
||||
)
|
||||
|
||||
fn from_port<A:send>(+port: future_pipe::client::waiting<A>) -> Future<A> {
|
||||
#[doc = "
|
||||
Create a future from a port
|
||||
|
||||
The first time that the value is requested the task will block
|
||||
waiting for the result to be received on the port.
|
||||
"];
|
||||
/*!
|
||||
* Create a future from a port
|
||||
*
|
||||
* The first time that the value is requested the task will block
|
||||
* waiting for the result to be received on the port.
|
||||
*/
|
||||
|
||||
let port = ~mut some(port);
|
||||
do from_fn |move port| {
|
||||
@ -82,7 +78,7 @@ fn from_port<A:send>(+port: future_pipe::client::waiting<A>) -> Future<A> {
|
||||
port_ <-> *port;
|
||||
let port = option::unwrap(port_);
|
||||
match recv(port) {
|
||||
future_pipe::completed(data) => move_it!(data)
|
||||
future_pipe::completed(move data) => data
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -325,6 +325,7 @@ unsafe fn get_buffer<T: send>(p: *packet_header) -> ~buffer<T> {
|
||||
transmute((*p).buf_header())
|
||||
}
|
||||
|
||||
// This could probably be done with SharedMutableState to avoid move_it!().
|
||||
struct buffer_resource<T: send> {
|
||||
let buffer: ~buffer<T>;
|
||||
new(+b: ~buffer<T>) {
|
||||
@ -962,8 +963,8 @@ impl<T: send> chan<T>: channel<T> {
|
||||
let mut endp = none;
|
||||
endp <-> self.endp;
|
||||
match move streamp::client::try_data(unwrap(endp), x) {
|
||||
some(next) => {
|
||||
self.endp = some(move_it!(next));
|
||||
some(move next) => {
|
||||
self.endp = some(next);
|
||||
true
|
||||
}
|
||||
none => false
|
||||
@ -984,9 +985,9 @@ impl<T: send> port<T>: recv<T> {
|
||||
let mut endp = none;
|
||||
endp <-> self.endp;
|
||||
match move pipes::try_recv(unwrap(endp)) {
|
||||
some(streamp::data(x, endp)) => {
|
||||
self.endp = some(move_it!(endp));
|
||||
some(move_it!(x))
|
||||
some(streamp::data(move x, move endp)) => {
|
||||
self.endp = some(endp);
|
||||
some(x)
|
||||
}
|
||||
none => none
|
||||
}
|
||||
@ -1029,12 +1030,8 @@ struct PortSet<T: send> : recv<T> {
|
||||
while result == none && ports.len() > 0 {
|
||||
let i = wait_many(ports);
|
||||
match move ports[i].try_recv() {
|
||||
// FIXME (#2329): use this version once move from enum works.
|
||||
//some(copy m) => {
|
||||
// result = some(move m);
|
||||
//}
|
||||
some(m) => {
|
||||
result = some(move_it!(m));
|
||||
some(move m) => {
|
||||
result = some(m);
|
||||
}
|
||||
none => {
|
||||
// Remove this port.
|
||||
@ -1047,12 +1044,7 @@ struct PortSet<T: send> : recv<T> {
|
||||
}
|
||||
|
||||
fn recv() -> T {
|
||||
match move self.try_recv() {
|
||||
// FIXME (#2329): use this version once move from enum works.
|
||||
//some(copy x) => move x,
|
||||
some(x) => move_it!(x),
|
||||
none => fail ~"port_set: endpoints closed"
|
||||
}
|
||||
option::unwrap_expect(self.try_recv(), "port_set: endpoints closed")
|
||||
}
|
||||
|
||||
pure fn peek() -> bool {
|
||||
|
Loading…
Reference in New Issue
Block a user