Method: Lockfile#new_refresher

Defined in:
lib/lockfile.rb

#new_refresherObject



384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
# File 'lib/lockfile.rb', line 384

def new_refresher
  Thread.new(Thread.current, @path, @refresh, @dont_use_lock_id) do |thread, path, refresh, dont_use_lock_id|
    loop do 
      begin
        touch path
        trace{"touched <#{ path }> @ <#{ Time.now.to_f }>"}
        unless dont_use_lock_id
          loaded = load_lock_id(IO.read(path))
          trace{"loaded <\n#{ loaded.inspect }\n>"}
          raise unless loaded == @lock_id 
        end
        sleep refresh
      rescue Exception => e
        trace{errmsg e}
        thread.raise StolenLockError
        Thread.exit
      end
    end
  end
end