File

net/cqueues.lua @ 10998:f3fc0f799dc4

util.indexedbheap: Add failing test case for #1572 This approximates what happens if you add a timer far in the future, then reschedule it to right now.
author Kim Alvefur <zash@zash.se>
date Wed, 08 Jul 2020 21:39:10 +0200
parent 10996:d742095046f9
child 10999:37b884d675f7
line wrap: on
line source

-- Prosody IM
-- Copyright (C) 2014 Daurnimator
--
-- This project is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
--
-- This module allows you to use cqueues with a net.server mainloop
--

local server = require "net.server";
local cqueues = require "cqueues";
assert(cqueues.VERSION >= 20150113, "cqueues newer than 20150113 required")

-- Create a single top level cqueue
local cq;

if server.cq then -- server provides cqueues object
	cq = server.cq;
elseif server.watchfd then
	cq = cqueues.new();
	server.watchfd(cq:pollfd(), function ()
		assert(cq:loop(0));
	end);
else
	error "NYI"
end

return {
	cq = cq;
}