<commit_before>local loader = function(loader, ...)
	local core = require("_cqueues")
	local monotime = core.monotime

	function core.poll(...)
		return coroutine.yield(...)
	end -- core.poll

	function core.sleep(timeout)
		core.poll(timeout)
	end -- core.sleep


	local function findwhy(x, ...)
		if x then
			if type(x) == "number" then
				return require"cqueues.errno".strerror(x) or x
			else
				return x
			end
		elseif select("#", ...) > 0 then
			return findwhy(...)
		else
			return
		end
	end

	function core.assert(x, ...)
		if x then
			return x, ...
		end

		return assert(false, findwhy(...))
	end -- core.assert

	local step; step = core.interpose("step", function (self, timeout)
		if core.running() then
			core.poll(self, timeout)

			return step(self, 0.0)
		else
			return step(self, timeout)
		end
	end) -- core:step

	core.interpose("loop", function (self, timeout)
		local ok, why

		if timeout then
			local curtime = monotime()
			local deadline = curtime + timeout<commit_msg>initial I/O polling extensions for nested coroutine polling<commit_after>local loader = function(loader, ...)
	local core = require"_cqueues"
	local errno = require"_cqueues.errno"
	local yield = coroutine.yield
	local resume = coroutine.resume
	local monotime = core.monotime
	local running = core.running
	local strerror = errno.strerror

	local _POLL = {}

	function core.poll(...)
		local _, immediate = running()

		if immediate then
			return yield(...)
		else
			return yield(_POLL, ...)
		end
	end -- core.poll

	function core.sleep(timeout)
		core.poll(timeout)
	end -- core.sleep

	--
	-- Provide coroutine wrappers for inline I/O polling of
	-- coroutine-wrapped code. The code checks for a special value
	-- returned by our poll routine (above), and will propogate a yield
	-- on I/O. Everything else should behave as usual.
	--
	local function _iresume(co, ok, arg1, ...)
		if ok and arg1 == _POLL then
			return core.iresume(co, yield(_POLL, ...))
		else
			return ok, arg1, ...
		end
	end -- _iresume

	function core.iresume(co, ...)
		return _iresume(co, resume(co, ...))
	end -- core.iresume

	local function _iwrap(co, ok, ...)
		if ok then
			return ...
		else
			error((...), 0)
		end
	end -- _iwrap

	function core.iwrap(f)
		local co = coroutine.create(f)

		return function(...)
			return _iwrap(co, _iresume(co, resume(co, ...))) 
		end
	end -- core.iwrap

	local function findwhy(x, ...)
		if x then
			if type(x) == "number" then
				return strerror(x) or x
			else
				return tostring(x)
			end
		elseif select("#", ...) > 0 then
			return findwhy(...)
		else
			return
		end
	end

	function core.assert(x, ...)
		if x then
			return x, ...
		end

		return error(findwhy(...), 2)
	end -- core.assert

	local step; step = core.interpose("step", function (self, timeout)
		if core.running() then
			core.poll(self, timeout)

			return step(self, 0.0)
		else
			return step(self, timeout)
		end
	end) -- core:step

	core.interpose("loop", function (self, timeout)
		local ok, why

		if timeout then
			local curtime = monotime()
			local deadline = curtime + timeout
{'fraction_non_alphanumeric': 0.1328377504848093, 'fraction_numerical': 0.003555268261150614, 'mean_word_length': 2.778998778998779, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '604833', 'n_tokens_mistral': 1194, 'n_tokens_neox': 1033, 'n_words': 325}