mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-31 00:53:48 +00:00
Enabling pipes for all stages, and updating closure syntax.
This commit is contained in:
parent
67b0760592
commit
a4838c93aa
@ -187,8 +187,6 @@ mod newcomm;
|
||||
mod comm;
|
||||
mod task;
|
||||
mod future;
|
||||
// TODO: remove the conditionals once a new snapshot happens
|
||||
#[cfg(stage1)]
|
||||
mod pipes;
|
||||
|
||||
// Runtime and language-primitive support
|
||||
|
@ -197,7 +197,7 @@ fn spawn_service<T: send>(
|
||||
// This is some nasty gymnastics required to safely move the pipe
|
||||
// into a new task.
|
||||
let server = ~mut some(server);
|
||||
task::spawn() {|move service|
|
||||
do task::spawn |move service| {
|
||||
let mut server_ = none;
|
||||
server_ <-> *server;
|
||||
service(option::unwrap(server_))
|
||||
|
@ -60,7 +60,7 @@ fn thread_ring(i: uint,
|
||||
let mut num_chan <- some(num_chan);
|
||||
let mut num_port <- some(num_port);
|
||||
// Send/Receive lots of messages.
|
||||
for uint::range(0u, count) {|j|
|
||||
for uint::range(0u, count) |j| {
|
||||
//#error("task %?, iter %?", i, j);
|
||||
let mut num_chan2 = none;
|
||||
let mut num_port2 = none;
|
||||
@ -97,13 +97,13 @@ fn main(args: [str]/~) {
|
||||
// create the ring
|
||||
let mut futures = []/~;
|
||||
|
||||
for uint::range(1u, num_tasks) {|i|
|
||||
for uint::range(1u, num_tasks) |i| {
|
||||
//#error("spawning %?", i);
|
||||
let (new_chan, num_port) = ring::init();
|
||||
let num_chan2 = ~mut none;
|
||||
*num_chan2 <-> num_chan;
|
||||
let num_port = ~mut some(num_port);
|
||||
futures += [future::spawn {|move num_chan2, move num_port|
|
||||
futures += [future::spawn(|move num_chan2, move num_port| {
|
||||
let mut num_chan = none;
|
||||
num_chan <-> *num_chan2;
|
||||
let mut num_port1 = none;
|
||||
@ -111,7 +111,7 @@ fn main(args: [str]/~) {
|
||||
thread_ring(i, msg_per_task,
|
||||
option::unwrap(num_chan),
|
||||
option::unwrap(num_port1))
|
||||
}]/~;
|
||||
})]/~;
|
||||
num_chan = some(new_chan);
|
||||
};
|
||||
|
||||
@ -119,7 +119,7 @@ fn main(args: [str]/~) {
|
||||
thread_ring(0u, msg_per_task, option::unwrap(num_chan), num_port);
|
||||
|
||||
// synchronize
|
||||
for futures.each {|f| f.get() };
|
||||
for futures.each |f| { f.get() };
|
||||
|
||||
let stop = time::precise_time_s();
|
||||
|
||||
|
@ -97,12 +97,12 @@ fn main() {
|
||||
let client_ = ~mut some(client_);
|
||||
let server_ = ~mut some(server_);
|
||||
|
||||
task::spawn {|move client_|
|
||||
do task::spawn |move client_| {
|
||||
let mut client__ = none;
|
||||
*client_ <-> client__;
|
||||
client(option::unwrap(client__));
|
||||
};
|
||||
task::spawn {|move server_|
|
||||
do task::spawn |move server_| {
|
||||
let mut server_ˊ = none;
|
||||
*server_ <-> server_ˊ;
|
||||
server(option::unwrap(server_ˊ));
|
||||
|
@ -258,12 +258,12 @@ fn main() {
|
||||
let client_ = ~mut some(client_);
|
||||
let server_ = ~mut some(server_);
|
||||
|
||||
task::spawn {|move client_|
|
||||
do task::spawn |move client_| {
|
||||
let mut client__ = none;
|
||||
*client_ <-> client__;
|
||||
client(option::unwrap(client__));
|
||||
};
|
||||
task::spawn {|move server_|
|
||||
do task::spawn |move server_| {
|
||||
let mut server_ˊ = none;
|
||||
*server_ <-> server_ˊ;
|
||||
server(option::unwrap(server_ˊ));
|
||||
|
@ -210,7 +210,7 @@ mod pingpong {
|
||||
|
||||
impl abominable for client::ping {
|
||||
fn send() -> fn@(-client::ping, ping) -> client::pong {
|
||||
{|pipe, data|
|
||||
|pipe, data| {
|
||||
let p = pipes::packet();
|
||||
pipes::send(pipe, pingpong::ping_message(p));
|
||||
pipes::recv_packet(p)
|
||||
@ -220,7 +220,7 @@ mod pingpong {
|
||||
|
||||
impl abominable for client::pong {
|
||||
fn recv() -> fn@(-client::pong) -> (client::ping, pong) {
|
||||
{|pipe|
|
||||
|pipe| {
|
||||
let packet = pipes::recv(pipe);
|
||||
if packet == none {
|
||||
fail "sender closed the connection"
|
||||
@ -238,7 +238,7 @@ mod pingpong {
|
||||
|
||||
impl abominable for server::ping {
|
||||
fn recv() -> fn@(-server::ping) -> (server::pong, ping) {
|
||||
{|pipe|
|
||||
|pipe| {
|
||||
let packet = pipes::recv(pipe);
|
||||
if packet == none {
|
||||
fail "sender closed the connection"
|
||||
@ -251,7 +251,7 @@ mod pingpong {
|
||||
|
||||
impl abominable for server::pong {
|
||||
fn send() -> fn@(-server::pong, pong) -> server::ping {
|
||||
{|pipe, data|
|
||||
|pipe, data| {
|
||||
let p = pipes::packet();
|
||||
pipes::send(pipe, pingpong::pong_message(p));
|
||||
pipes::recv_packet(p)
|
||||
@ -294,12 +294,12 @@ fn main() {
|
||||
let client_ = ~mut some(client_);
|
||||
let server_ = ~mut some(server_);
|
||||
|
||||
task::spawn {|move client_|
|
||||
do task::spawn |move client_| {
|
||||
let mut client__ = none;
|
||||
*client_ <-> client__;
|
||||
test::client(option::unwrap(client__));
|
||||
};
|
||||
task::spawn {|move server_|
|
||||
do task::spawn |move server_| {
|
||||
let mut server_ˊ = none;
|
||||
*server_ <-> server_ˊ;
|
||||
test::server(option::unwrap(server_ˊ));
|
||||
|
@ -48,9 +48,7 @@ fn main() {
|
||||
chan.recv()(chan)]
|
||||
];
|
||||
|
||||
let c = pipes::spawn_service(oneshot::init) {|p|
|
||||
#recv(p);
|
||||
};
|
||||
let c = pipes::spawn_service(oneshot::init, |p| { #recv(p); });
|
||||
|
||||
let iotask = uv::global_loop::get();
|
||||
sleep(iotask, 5000);
|
||||
|
Loading…
Reference in New Issue
Block a user