summaryrefslogtreecommitdiff
path: root/test.lua
blob: d70f7f28b6e594035ce42676606af73268543970 (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
local cqueues = require'cqueues'
local condition = require'cqueues.condition'

local cv = condition.new()
local function task1()
	while true do
		print('1 top')
		cv:wait()
		print('1 waited')
	end
end
local function task2()
	while true do
		print('2 top')
		cv:signal()
		print('2 signalled')
		cqueues.poll()
	end
end

local cq = cqueues.new()
cq:wrap(task1)
cq:wrap(task2)
print(cq:loop())