Class: Concurrent::Channel::Tick
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
|
|
Instance Chain:
self,
Comparable,
Synchronization::Object ,
Synchronization::Volatile ,
Synchronization::AbstractObject
|
|
Inherits: |
Concurrent::Synchronization::Object
|
Defined in: | lib/concurrent-ruby-edge/concurrent/channel/tick.rb |
Overview
A convenience class representing a single moment in monotonic time. Returned by Channel
tickers and timers when they resolve.
Includes Comparable
and can be compared to monotonic_time, UTC time, or epoch time.
Constant Summary
-
STRING_FORMAT =
# File 'lib/concurrent-ruby-edge/concurrent/channel/tick.rb', line 21'%F %T.%6N %z %Z'.freeze
Class Attribute Summary
Synchronization::Object
- Inherited
Class Method Summary
- .new(tick = Concurrent.monotonic_time) ⇒ Tick constructor
Synchronization::Object
- Inherited
.atomic_attribute?, .atomic_attributes, | |
.attr_atomic | Creates methods for reading and writing to a instance variable with volatile (Java) semantic as |
.attr_volatile | Creates methods for reading and writing (as |
.ensure_safe_initialization_when_final_fields_are_present | For testing purposes, quite slow. |
.new | Has to be called by children. |
.safe_initialization!, .define_initialize_atomic_fields |
Synchronization::AbstractObject
- Inherited
Instance Attribute Summary
- #monotonic readonly
- #utc readonly
Instance Method Summary
Synchronization::Object
- Inherited
Synchronization::Volatile
- Included
Synchronization::AbstractObject
- Inherited
Constructor Details
.new(tick = Concurrent.monotonic_time) ⇒ Tick
# File 'lib/concurrent-ruby-edge/concurrent/channel/tick.rb', line 25
def initialize(tick = Concurrent.monotonic_time) @monotonic = tick @utc = monotonic_to_utc(tick).freeze end
Instance Attribute Details
#monotonic (readonly)
[ GitHub ]# File 'lib/concurrent-ruby-edge/concurrent/channel/tick.rb', line 23
attr_reader :monotonic, :utc
#utc (readonly)
[ GitHub ]# File 'lib/concurrent-ruby-edge/concurrent/channel/tick.rb', line 23
attr_reader :monotonic, :utc
Instance Method Details
#<=>(other)
[ GitHub ]#epoch
[ GitHub ]# File 'lib/concurrent-ruby-edge/concurrent/channel/tick.rb', line 30
def epoch @utc.to_f end
#monotonic_to_utc(tick) (private)
[ GitHub ]# File 'lib/concurrent-ruby-edge/concurrent/channel/tick.rb', line 52
def monotonic_to_utc(tick) Time.now.utc + Concurrent.monotonic_time - tick end
#to_s
[ GitHub ]# File 'lib/concurrent-ruby-edge/concurrent/channel/tick.rb', line 34
def to_s @utc.strftime(STRING_FORMAT) end