Class: Concurrent::Channel::Buffer::Ticker
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Class Chain:
|
|
|
Instance Chain:
|
|
| Inherits: |
Concurrent::Channel::Buffer::Timer
|
| Defined in: | lib/concurrent-ruby-edge/concurrent/channel/buffer/ticker.rb |
Class Method Summary
Instance Attribute Summary
Timer - Inherited
Base - Inherited
| #blocking? | Predicate indicating if this buffer will block Concurrent::Channel#put operations once it reaches its maximum capacity. |
| #capacity | The maximum number of values which can be Concurrent::Channel#put onto the buffer it becomes full. |
| #closed? | Predicate indicating is this buffer closed. |
| #empty? | Predicate indicating if the buffer is empty. |
| #full? | Predicate indicating if the buffer is full. |
| #size | The number of items currently in the buffer. |
| #buffer, #buffer=, #capacity=, #closed=, | |
| #ns_closed? | Predicate indicating is this buffer closed. |
| #ns_empty? | Predicate indicating if the buffer is empty. |
| #ns_full? | Predicate indicating if the buffer is full. |
| #size= | |
Instance Method Summary
- #do_poll private
- #ns_initialize(interval) private
Timer - Inherited
Base - Inherited
| #close | Close the buffer, preventing new items from being added. |
| #next | Take the next “item” from the buffer and also return a boolean indicating if “more” items can be taken. |
| #offer | Put an item onto the buffer if possible. |
| #poll | Take the next item from the buffer if one is available else return immediately. |
| #put | Put an item onto the buffer if possible. |
| #take | Take an item from the buffer if one is available. |
| #ns_initialize, | |
| #ns_size | The number of items currently in the buffer. |
Synchronization::LockableObject - Inherited
Constructor Details
This class inherits a constructor from Concurrent::Channel::Buffer::Base
Instance Method Details
#do_poll (private)
[ GitHub ]# File 'lib/concurrent-ruby-edge/concurrent/channel/buffer/ticker.rb', line 20
def do_poll synchronize do if ns_closed? return Concurrent::NULL, false elsif (now = Concurrent.monotonic_time) >= @next_tick tick = Concurrent::Channel::Tick.new(@next_tick) @next_tick = now + @interval return tick, true else return nil, true end end end
#ns_initialize(interval) (private)
[ GitHub ]# File 'lib/concurrent-ruby-edge/concurrent/channel/buffer/ticker.rb', line 14
def ns_initialize(interval) @interval = interval.to_f @next_tick = Concurrent.monotonic_time + interval self.capacity = 1 end