test-stress.lua

---
-- A test program with two tasks, one emitting signals and the other accepting them.
--See how fast it can run.

--look for packages one folder up.
package.path = package.path .. ";;;../../?.lua;../../?/init.lua"

--require "strict"
--require "profiler"

local sched = require "lumen.sched"

local i=0

--profiler.start('profiler.out')

-- task emits as fast as it can (but also yields to be realistic)
local emitter_task=sched.run(function()
	while true do
		sched.signal('ev', 'data!')
		sched.wait()
	end
end)

-- task receives the messages and counts them
sched.run(function()
	local waitd={'ev'}
	while true do
		--uncomment this to create huge ammount of waitds:
		--local waitd={'ev','ev'..i}
		sched.wait(waitd)
		i=i+1
		if i==1000000 then
			--profiler.stop()
			os.exit()
		end
	end
end)

sched.loop()
generated by LDoc 1.4.6 Last updated 2021-07-05 12:15:43