Class: RSwim::Agent::PushBased
- Inherits:
-
Object
- Object
- RSwim::Agent::PushBased
- Defined in:
- lib/rswim/agent.rb
Overview
Non-blocking agent that is explicitly advanced
Instance Method Summary collapse
- #advance(messages) ⇒ Object
- #append_custom_state(key, value) ⇒ Object
-
#initialize(node_member_id, seed_member_ids, t_ms, r_ms) ⇒ PushBased
constructor
A new instance of PushBased.
- #run ⇒ Object
- #subscribe(&block) ⇒ Object
Constructor Details
#initialize(node_member_id, seed_member_ids, t_ms, r_ms) ⇒ PushBased
Returns a new instance of PushBased.
7 8 9 |
# File 'lib/rswim/agent.rb', line 7 def initialize(node_member_id, seed_member_ids, t_ms, r_ms) @state = new_protocol_state(node_member_id, seed_member_ids, t_ms, r_ms) end |
Instance Method Details
#advance(messages) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/rswim/agent.rb', line 23 def advance() raise 'not running' if @t0.nil? t1 = monotonic_seconds elapsed_seconds = t1 - @t0 @t0 = t1 @state.advance(, elapsed_seconds) end |
#append_custom_state(key, value) ⇒ Object
15 16 17 |
# File 'lib/rswim/agent.rb', line 15 def append_custom_state(key, value) @state.append_custom_state(key, value) end |
#run ⇒ Object
19 20 21 |
# File 'lib/rswim/agent.rb', line 19 def run @t0 = monotonic_seconds end |
#subscribe(&block) ⇒ Object
11 12 13 |
# File 'lib/rswim/agent.rb', line 11 def subscribe(&block) @state.subscribe(&block) end |