aboutsummaryrefslogtreecommitdiff
path: root/tests/atexit.lua
blob: 9fc30709a2825e9a0a110b74d76fa4b8f4d06266 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
local lanes = require "lanes" -- auto configure

-- create a free-running lane

local linda = lanes.linda()

local f = function( _linda)
	_linda:receive("oy")
end

local g = function()
	local cancelled
	repeat
		cancelled = cancel_test()
	until cancelled
	print "User cancellation detected!"
end

local genF = lanes.gen( "", {globals = {threadName = "mylane"}}, f)
local genG = lanes.gen( "", g)


-- launch a good batch of free running lanes
for i = 1, 10 do
	-- if i%50 == 0 then print( i) end
	local h = genF( linda)
	local status
	repeat
		status = h.status
		--print( status)
	until status == "waiting"

	-- [[
	local h = genG()
	local status
	repeat
		status = h.status
		--print( status)
	until status == "running"
	--]]
end

print "exiting"

-- let process end terminate them and see what happens