Class: RSwim::IOLoop
- Inherits:
-
Object
- Object
- RSwim::IOLoop
- Defined in:
- lib/rswim/io_loop.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(agent, serializer, deserializer, directory, sleep_time_seconds) ⇒ IOLoop
constructor
A new instance of IOLoop.
- #run ⇒ Object
Constructor Details
#initialize(agent, serializer, deserializer, directory, sleep_time_seconds) ⇒ IOLoop
Returns a new instance of IOLoop.
5 6 7 8 9 10 11 12 |
# File 'lib/rswim/io_loop.rb', line 5 def initialize(agent, serializer, deserializer, directory, sleep_time_seconds) @agent = agent @serializer = serializer @deserializer = deserializer @directory = directory @sleep_time_seconds = sleep_time_seconds @read_buffer = [] end |
Instance Method Details
#run ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rswim/io_loop.rb', line 14 def run Async do before_run start_producer loop do = consume_read_buffer logger.debug "advancing agent with #{.size} messages" = @agent.advance() = .map do || = @serializer.serialize() host = @directory.host(.to) [host, ] end logger.debug "sending #{.size} messages from agent to other hosts" send() rescue StandardError => e logger.debug("Error in I/O loop: #{e}") end logger.info 'node no longer receiving' end end |