Sha256: ceb507bf28e557dee4c873a0521f4fb3d8bf963a0374d2d2c5c39cdb2262157d

Contents?: true

Size: 802 Bytes

Versions: 59

Compression:

Stored size: 802 Bytes

Contents

module Skylight
  module Util
    class Clock

      if Skylight.native?
        def tick
          native_hrtime
        end
      else
        def tick
          now = Time.now
          now.to_i * 1_000_000_000 + now.usec * 1_000
        end
      end

      # TODO: rename to secs
      def absolute_secs
        Time.now.to_i
      end

      # TODO: remove
      def nanos
        tick
      end

      # TODO: remove
      def secs
        nanos / 1_000_000_000
      end

      def self.absolute_secs
        default.absolute_secs
      end

      def self.nanos
        default.nanos
      end

      def self.secs
        default.secs
      end

      def self.default
        @clock ||= Clock.new
      end

      def self.default=(clock)
        @clock = clock
      end

    end
  end
end

Version data entries

59 entries across 59 versions & 2 rubygems

Version Path
skylight-1.4.0.beta lib/skylight/util/clock.rb
skylight-1.3.1 lib/skylight/util/clock.rb
skylight-1.3.0 lib/skylight/util/clock.rb
skylight-1.2.2 lib/skylight/util/clock.rb
skylight-1.2.1 lib/skylight/util/clock.rb
skylight-1.2.0 lib/skylight/util/clock.rb
skylight-1.1.0 lib/skylight/util/clock.rb
skylight-1.0.1 lib/skylight/util/clock.rb
skylight-1.0.0 lib/skylight/util/clock.rb
skylight-0.10.6 lib/skylight/util/clock.rb
skylight-1.0.0.beta5 lib/skylight/util/clock.rb
skylight-0.10.5 lib/skylight/util/clock.rb
skylight-0.10.4 lib/skylight/util/clock.rb
skylight-1.0.0.beta4 lib/skylight/util/clock.rb
skylight-1.0.0.beta3 lib/skylight/util/clock.rb
skylight-0.10.3 lib/skylight/util/clock.rb
skylight-0.10.2 lib/skylight/util/clock.rb
skylight-1.0.0.beta2 lib/skylight/util/clock.rb
skylight-0.10.0 lib/skylight/util/clock.rb
skylight-0.9.4 lib/skylight/util/clock.rb