Browse Source

Small CooperativeScheduler fixes;

bjorn 9 years ago
parent
commit
88dcf85d5e
2 changed files with 10 additions and 6 deletions
  1. 5 3
      rx.lua
  2. 5 3
      src/schedulers/cooperativescheduler.lua

+ 5 - 3
rx.lua

@@ -1694,7 +1694,7 @@ CooperativeScheduler.__tostring = util.constant('CooperativeScheduler')
 
 
 --- Creates a new CooperativeScheduler.
 --- Creates a new CooperativeScheduler.
 -- @arg {number=0} currentTime - A time to start the scheduler at.
 -- @arg {number=0} currentTime - A time to start the scheduler at.
--- @returns {Scheduler.CooperativeScheduler}
+-- @returns {CooperativeScheduler}
 function CooperativeScheduler.create(currentTime)
 function CooperativeScheduler.create(currentTime)
   local self = {
   local self = {
     tasks = {},
     tasks = {},
@@ -1704,11 +1704,13 @@ function CooperativeScheduler.create(currentTime)
   return setmetatable(self, CooperativeScheduler)
   return setmetatable(self, CooperativeScheduler)
 end
 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
 -- @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
 --                          coroutine may yield execution back to the scheduler with an optional
 --                          number, which will put it to sleep for a time period.
 --                          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)
 function CooperativeScheduler:schedule(action, delay)
   local task = {
   local task = {
     thread = coroutine.create(action),
     thread = coroutine.create(action),

+ 5 - 3
src/schedulers/cooperativescheduler.lua

@@ -10,7 +10,7 @@ CooperativeScheduler.__tostring = util.constant('CooperativeScheduler')
 
 
 --- Creates a new CooperativeScheduler.
 --- Creates a new CooperativeScheduler.
 -- @arg {number=0} currentTime - A time to start the scheduler at.
 -- @arg {number=0} currentTime - A time to start the scheduler at.
--- @returns {Scheduler.CooperativeScheduler}
+-- @returns {CooperativeScheduler}
 function CooperativeScheduler.create(currentTime)
 function CooperativeScheduler.create(currentTime)
   local self = {
   local self = {
     tasks = {},
     tasks = {},
@@ -20,11 +20,13 @@ function CooperativeScheduler.create(currentTime)
   return setmetatable(self, CooperativeScheduler)
   return setmetatable(self, CooperativeScheduler)
 end
 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
 -- @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
 --                          coroutine may yield execution back to the scheduler with an optional
 --                          number, which will put it to sleep for a time period.
 --                          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)
 function CooperativeScheduler:schedule(action, delay)
   local task = {
   local task = {
     thread = coroutine.create(action),
     thread = coroutine.create(action),