Class: OllamaAgent::Runtime::LogicalClock
- Inherits:
-
Object
- Object
- OllamaAgent::Runtime::LogicalClock
- Defined in:
- lib/ollama_agent/runtime/logical_clock.rb
Overview
Monotonic logical stamps for orchestration (no wall clock / Time.now).
Instance Method Summary collapse
-
#initialize(epoch: 0) ⇒ LogicalClock
constructor
A new instance of LogicalClock.
-
#next_stamp ⇒ String
Next logical stamp, e.g.
Constructor Details
#initialize(epoch: 0) ⇒ LogicalClock
Returns a new instance of LogicalClock.
7 8 9 10 11 |
# File 'lib/ollama_agent/runtime/logical_clock.rb', line 7 def initialize(epoch: 0) @epoch = epoch.to_i @sequence = 0 @mutex = Mutex.new end |
Instance Method Details
#next_stamp ⇒ String
Returns next logical stamp, e.g. “0:1”.
14 15 16 17 18 19 |
# File 'lib/ollama_agent/runtime/logical_clock.rb', line 14 def next_stamp @mutex.synchronize do @sequence += 1 "#{@epoch}:#{@sequence}" end end |