Skip to content

Commit c81edbc

Browse files
committed
run GC sweeps more often since we most likely will have the time
1 parent b2e55bb commit c81edbc

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

lib/zhong/job.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,20 @@ def run(time = Time.now)
4040
end
4141

4242
@thread = nil
43+
locked = false
44+
45+
@lock.lock do
46+
locked = true
4347

44-
ran_set = @lock.lock do
4548
refresh_last_ran
4649

47-
break true unless run?(time)
50+
# we need to check again, as another process might have acquired
51+
# the lock right before us and obviated our need to do anything
52+
break unless run?(time)
4853

4954
if disabled?
5055
@logger.info "disabled: #{self}"
51-
break true
56+
break
5257
end
5358

5459
@logger.info "running: #{self}"
@@ -58,7 +63,7 @@ def run(time = Time.now)
5863
ran!(time)
5964
end
6065

61-
@logger.info "unable to acquire exclusive run lock: #{self}" unless ran_set
66+
@logger.info "unable to acquire exclusive run lock: #{self}" unless locked
6267
end
6368

6469
def stop

lib/zhong/scheduler.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ def start
6363

6464
fire_callbacks(:after_tick)
6565

66+
GC.start
67+
6668
sleep(interval)
6769
end
6870

0 commit comments

Comments
 (0)