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