-- Main function that is executed when the module is used

local default_wait = 1/60
local function FastWait(wait_time)
	-- Verifies [wait_time]
	wait_time = tonumber(wait_time) or (default_wait)

	-- Mark [start] time
	local start = os.clock()

	-- Get running [thread]
	local thread = coroutine.running()

	-- Insert it in [threads] table
	threads[n_threads + 1] = thread
	threads[n_threads + 2] = (start + wait_time)

	n_threads += 2

	-- Wait until the coroutine resumes (the yielding finishes)
	local current_time = coroutine.yield()

	-- Return: (time_it_waited, current_time)
	return (current_time - start), current_time
end

return FastWait
