summaryrefslogtreecommitdiff
path: root/lib/thread/test/future.myr
blob: 760404b7fc50cf985d7bf2d51f77fa3407bf50a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use std
use sys
use thread

const main = {
	var f

	f = thread.mkfut()
	thread.futput(f, 123)
	std.assert(thread.futget(f) == 123, "the future is broken\n")

	f = thread.mkfut()
	thread.spawn({
		std.usleep(10_000)
		thread.futput(f, 321)
	})
	std.assert(thread.futget(f) == 321, "the future is broken\n")
}