Class: StatelyDB::Transaction::Queue
- Inherits:
-
Thread::Queue
- Object
- Thread::Queue
- StatelyDB::Transaction::Queue
- Defined in:
- lib/transaction/queue.rb
Overview
TransactionQueue is a wrapper around Thread::Queue that implements Enumerable
Instance Attribute Summary collapse
-
#last_message_id ⇒ Integer?
readonly
The ID of the last message, or nil if there is no message.
Instance Method Summary collapse
-
#each {|Object| ... } ⇒ void
Iterates over each element in the queue, yielding each element to the given block.
-
#each_item {|Object| ... } ⇒ void
Iterates over each item in the queue, yielding each item to the given block.
-
#initialize ⇒ Queue
constructor
A new instance of Queue.
-
#next_message_id ⇒ Integer
next_message_id returns the next message ID, which is the current size of the queue + 1.
Constructor Details
#initialize ⇒ Queue
Returns a new instance of Queue.
11 12 13 14 |
# File 'lib/transaction/queue.rb', line 11 def initialize super = 0 end |
Instance Attribute Details
#last_message_id ⇒ Integer? (readonly)
Returns The ID of the last message, or nil if there is no message.
9 10 11 |
# File 'lib/transaction/queue.rb', line 9 def end |
Instance Method Details
#each {|Object| ... } ⇒ void
This method returns an undefined value.
Iterates over each element in the queue, yielding each element to the given block.
27 28 29 30 31 |
# File 'lib/transaction/queue.rb', line 27 def each loop do yield pop end end |
#each_item {|Object| ... } ⇒ void
This method returns an undefined value.
Iterates over each item in the queue, yielding each item to the given block.
37 38 39 40 41 |
# File 'lib/transaction/queue.rb', line 37 def each_item loop do yield pop end end |
#next_message_id ⇒ Integer
next_message_id returns the next message ID, which is the current size of the queue + 1. This value is consumed by the StatelyDB transaction as a monotonically increasing MessageID.
19 20 21 |
# File 'lib/transaction/queue.rb', line 19 def += 1 end |