Small CooperativeScheduler fixes;

This commit is contained in:
bjorn 2015-11-20 20:13:14 -08:00
parent b76c2d5f53
commit 88dcf85d5e
2 changed files with 10 additions and 6 deletions

8
rx.lua
View File

@ -1694,7 +1694,7 @@ CooperativeScheduler.__tostring = util.constant('CooperativeScheduler')
--- Creates a new CooperativeScheduler.
-- @arg {number=0} currentTime - A time to start the scheduler at.
-- @returns {Scheduler.CooperativeScheduler}
-- @returns {CooperativeScheduler}
function CooperativeScheduler.create(currentTime)
local self = {
tasks = {},
@ -1704,11 +1704,13 @@ function CooperativeScheduler.create(currentTime)
return setmetatable(self, CooperativeScheduler)
end
--- Schedules a function to be run after an optional delay.
--- Schedules a function to be run after an optional delay. Returns a subscription that will stop
-- the action from running.
-- @arg {function} action - The function to execute. Will be converted into a coroutine. The
-- coroutine may yield execution back to the scheduler with an optional
-- number, which will put it to sleep for a time period.
-- @arg {number=0} delay - Delay execution of the action by a time period.
-- @arg {number=0} delay - Delay execution of the action by a virtual time period.
-- @returns {Subscription}
function CooperativeScheduler:schedule(action, delay)
local task = {
thread = coroutine.create(action),

View File

@ -10,7 +10,7 @@ CooperativeScheduler.__tostring = util.constant('CooperativeScheduler')
--- Creates a new CooperativeScheduler.
-- @arg {number=0} currentTime - A time to start the scheduler at.
-- @returns {Scheduler.CooperativeScheduler}
-- @returns {CooperativeScheduler}
function CooperativeScheduler.create(currentTime)
local self = {
tasks = {},
@ -20,11 +20,13 @@ function CooperativeScheduler.create(currentTime)
return setmetatable(self, CooperativeScheduler)
end
--- Schedules a function to be run after an optional delay.
--- Schedules a function to be run after an optional delay. Returns a subscription that will stop
-- the action from running.
-- @arg {function} action - The function to execute. Will be converted into a coroutine. The
-- coroutine may yield execution back to the scheduler with an optional
-- number, which will put it to sleep for a time period.
-- @arg {number=0} delay - Delay execution of the action by a time period.
-- @arg {number=0} delay - Delay execution of the action by a virtual time period.
-- @returns {Subscription}
function CooperativeScheduler:schedule(action, delay)
local task = {
thread = coroutine.create(action),