mirror of
https://github.com/endofunky/sidetiq.git
synced 2022-11-09 13:53:30 -05:00
Adjust clock sleep based on schedule processing.
This commit is contained in:
parent
3c506f5bad
commit
22bae20d15
1 changed files with 12 additions and 3 deletions
|
@ -160,11 +160,20 @@ module Sidetiq
|
|||
|
||||
def clock
|
||||
loop do
|
||||
yield
|
||||
sleep_time = time { yield }
|
||||
|
||||
if sleep_time > 0
|
||||
Thread.pass
|
||||
sleep Sidetiq.config.resolution
|
||||
sleep sleep_time
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def time
|
||||
start = gettime
|
||||
yield
|
||||
Sidetiq.config.resolution - (gettime.to_f - start.to_f)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue