Class: Skylight::Core::Util::Clock Private
- Inherits:
-
Object
- Object
- Skylight::Core::Util::Clock
- 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
- .absolute_secs ⇒ Object private
- .default ⇒ Object private
- .default=(clock) ⇒ Object private
- .nanos ⇒ Object private
- .secs ⇒ Object private
- .use_native! ⇒ Object private
Instance Method Summary collapse
-
#absolute_secs ⇒ Object
private
TODO: rename to secs.
-
#nanos ⇒ Object
private
TODO: remove.
-
#secs ⇒ Object
private
TODO: remove.
- #tick ⇒ Object private
Class Method Details
.absolute_secs ⇒ 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.
34 35 36 |
# File 'lib/skylight/core/util/clock.rb', line 34 def self.absolute_secs default.absolute_secs end |
.default ⇒ 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.
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 |
.nanos ⇒ 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.
38 39 40 |
# File 'lib/skylight/core/util/clock.rb', line 38 def self.nanos default.nanos end |
.secs ⇒ 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.
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_secs ⇒ 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.
TODO: rename to secs
20 21 22 |
# File 'lib/skylight/core/util/clock.rb', line 20 def absolute_secs Time.now.to_i end |
#nanos ⇒ 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.
TODO: remove
25 26 27 |
# File 'lib/skylight/core/util/clock.rb', line 25 def nanos tick end |
#secs ⇒ 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.
TODO: remove
30 31 32 |
# File 'lib/skylight/core/util/clock.rb', line 30 def secs nanos / 1_000_000_000 end |
#tick ⇒ 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.
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 |