Skip to content

Commit

Permalink
run GC sweeps more often since we most likely will have the time
Browse files Browse the repository at this point in the history
  • Loading branch information
nickelser committed May 7, 2015
1 parent b2e55bb commit c81edbc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/zhong/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,20 @@ def run(time = Time.now)
end

@thread = nil
locked = false

@lock.lock do
locked = true

ran_set = @lock.lock do
refresh_last_ran

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

if disabled?
@logger.info "disabled: #{self}"
break true
break
end

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

@logger.info "unable to acquire exclusive run lock: #{self}" unless ran_set
@logger.info "unable to acquire exclusive run lock: #{self}" unless locked
end

def stop
Expand Down
2 changes: 2 additions & 0 deletions lib/zhong/scheduler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ def start

fire_callbacks(:after_tick)

GC.start

sleep(interval)
end

Expand Down

0 comments on commit c81edbc

Please sign in to comment.