Skip to content

Instantly share code, notes, and snippets.

@robarnold
Created July 28, 2011 04:35
Show Gist options
  • Save robarnold/1110969 to your computer and use it in GitHub Desktop.
Save robarnold/1110969 to your computer and use it in GitHub Desktop.
Minimal-ish test case
use std;
import std::task;
tag request {
quit;
close(int, chan[bool]);
}
type ctx = chan[request];
fn request_task(chan[ctx] c) {
let port[request] p = port();
c <| chan(p);
let request req;
while (true) {
p |> req;
alt (req) {
case (quit) {
ret;
}
case (close(?what, ?status)) {
log "closing now";
log what;
status <| true;
}
}
}
}
fn new() -> ctx {
let port[ctx] p = port();
let task t = spawn request_task(chan(p));
let ctx cx;
p |> cx;
ret cx;
}
fn main() {
let ctx cx = new();
let port[bool] p = port();
cx <| close(4, chan(p));
let bool result;
p |> result;
cx <| quit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment