Class: Skylight::Core::Util::Clock Private

Inherits:
Object
  • Object
show all
Defined in:
lib/skylight/core/util/clock.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A more precise clock

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.absolute_secsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



34
35
36
# File 'lib/skylight/core/util/clock.rb', line 34

def self.absolute_secs
  default.absolute_secs
end

.defaultObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



46
47
48
# File 'lib/skylight/core/util/clock.rb', line 46

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

.default=(clock) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



50
51
52
# File 'lib/skylight/core/util/clock.rb', line 50

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

.nanosObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



38
39
40
# File 'lib/skylight/core/util/clock.rb', line 38

def self.nanos
  default.nanos
end

.secsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



42
43
44
# File 'lib/skylight/core/util/clock.rb', line 42

def self.secs
  default.secs
end

.use_native!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



6
7
8
9
10
11
12
# File 'lib/skylight/core/util/clock.rb', line 6

def self.use_native!
  class_eval do
    def tick
      native_hrtime
    end
  end
end

Instance Method Details

#absolute_secsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

TODO: rename to secs



20
21
22
# File 'lib/skylight/core/util/clock.rb', line 20

def absolute_secs
  Time.now.to_i
end

#nanosObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

TODO: remove



25
26
27
# File 'lib/skylight/core/util/clock.rb', line 25

def nanos
  tick
end

#secsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

TODO: remove



30
31
32
# File 'lib/skylight/core/util/clock.rb', line 30

def secs
  nanos / 1_000_000_000
end

#tickObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



14
15
16
17
# File 'lib/skylight/core/util/clock.rb', line 14

def tick
  now = Time.now
  now.to_i * 1_000_000_000 + now.usec * 1_000
end