summaryrefslogtreecommitdiff
path: root/lib/thread/test/do.myr
blob: e2e64e8be22139da578c4c31c8e6b9d283806043 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use std
use thread

const main = {
	match std.espork(["echo", "hello"][:])
	| `std.Err e:
		std.fatal("could not spork\n")
	| `std.Ok (pid, in, out, err):
		std.close(in)
		var w = thread.do({;-> std.wait(pid)})
		var o = thread.do({;-> std.fslurp(out)})
		var e = thread.do({;-> std.fslurp(err)})

		match thread.futget(w)
		| `std.Wsuccess:	/* ok */
		| bad:	std.fatal("bad wait: {}\n", bad)
		;;

		match thread.futget(o)
		| `std.Ok "hello\n":	/* ok */
		| bad:	std.fatal("bad out: {}\n", bad)
		;;

		match thread.futget(e)
		| `std.Ok "":	/* ok */
		| bad:	std.fatal("bad err: {}\n", bad)
		;;
	;;
}