summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/luv/examples/cqueues-main.lua
blob: ff60ec2b1c96e75ffd74e596292393ca82d621aa (plain) (blame)
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
--[[
Demonstrates using luv with a cqueues mainloop
]]

local cqueues = require "cqueues"
local uv = require "luv"

local cq = cqueues.new()

cq:wrap(function()
	while cqueues.poll({
		pollfd = uv.backend_fd();
		timeout = uv.backend_timeout() / 1000;
		events = "r";
	}) do
		uv.run("nowait")
	end
end)

cq:wrap(function()
	while true do
		cqueues.sleep(1)
		print("HELLO FROM CQUEUES")
	end
end)

uv.new_timer():start(1000, 1000, function()
	print("HELLO FROM LUV")
end)

assert(cq:loop())