Class: Purplelight::WriterJSONL::PartSequence
- Inherits:
-
Object
- Object
- Purplelight::WriterJSONL::PartSequence
- Defined in:
- lib/purplelight/writer_jsonl.rb
Overview
Allocates globally unique output part numbers across writer threads.
Instance Method Summary collapse
-
#initialize(next_value = 0) ⇒ PartSequence
constructor
A new instance of PartSequence.
- #next ⇒ Object
Constructor Details
#initialize(next_value = 0) ⇒ PartSequence
Returns a new instance of PartSequence.
29 30 31 32 |
# File 'lib/purplelight/writer_jsonl.rb', line 29 def initialize(next_value = 0) @next_value = next_value @mutex = Mutex.new end |
Instance Method Details
#next ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/purplelight/writer_jsonl.rb', line 34 def next @mutex.synchronize do value = @next_value @next_value += 1 value end end |