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
|
def clock
|
||||||
loop do
|
loop do
|
||||||
yield
|
sleep_time = time { yield }
|
||||||
Thread.pass
|
|
||||||
sleep Sidetiq.config.resolution
|
if sleep_time > 0
|
||||||
|
Thread.pass
|
||||||
|
sleep sleep_time
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def time
|
||||||
|
start = gettime
|
||||||
|
yield
|
||||||
|
Sidetiq.config.resolution - (gettime.to_f - start.to_f)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue