Sha256: 4fd7954a88a1116b9b96c2dc04c297e0a5300db9782a52263e7f108c2e18fe8e

Contents?: true

Size: 663 Bytes

Versions: 1

Compression:

Stored size: 663 Bytes

Contents

require "clearsight/version"
require "clearsight/deploy"
require "clearsight/middleman"
require "clearsight/xcode"
require 'thread'

module Clearsight
  class Timer
    def initialize(interval, &handler)
      @run = true
      @semaphore = Mutex.new

      @th = Thread.new do
        t = Time.now
        while run?
          t += interval
          (sleep(t - Time.now) rescue nil) and handler.call rescue nil
        end
      end
    end

    def stop
      @semaphore.synchronize do
        @run = false
      end
      @th.join
    end

    private

    def run?
      @semaphore.synchronize do
        @run
      end
    end
  end
end
::CS = ::Clearsight

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
clearsight-1.1.0 lib/clearsight.rb