Class: Loupe::QueueServer
- Inherits:
-
Object
- Object
- Loupe::QueueServer
- Defined in:
- lib/loupe/queue_server.rb
Overview
Server
This object is the one passed to DRb in order to communicate between worker and server processes and coordinate both the queue and the reporting results
Instance Method Summary collapse
-
#add_reporter(other) ⇒ void
add_reporter.
- #empty? ⇒ Boolean
-
#initialize(queue, reporter) ⇒ Loupe::Server
constructor
The two operations we need to synchronize between the main process and its children is the queue and the reporter.
- #length ⇒ Integer
- #pop ⇒ Array<Class, Symbol>
Constructor Details
#initialize(queue, reporter) ⇒ Loupe::Server
The two operations we need to synchronize between the main process and its children is the queue and the reporter. We need to share the queue, so that workers can pop the tests from it and we need to share the reporter, so that workers can update the results
18 19 20 21 |
# File 'lib/loupe/queue_server.rb', line 18 def initialize(queue, reporter) @queue = queue @reporter = reporter end |
Instance Method Details
#add_reporter(other) ⇒ void
This method returns an undefined value.
add_reporter
Adds a temporary reporter from a child process into the main reporter to aggregate results
30 31 32 |
# File 'lib/loupe/queue_server.rb', line 30 def add_reporter(other) @reporter << other end |
#empty? ⇒ Boolean
45 46 47 |
# File 'lib/loupe/queue_server.rb', line 45 def empty? @queue.empty? end |
#length ⇒ Integer
40 41 42 |
# File 'lib/loupe/queue_server.rb', line 40 def length @queue.length end |
#pop ⇒ Array<Class, Symbol>
35 36 37 |
# File 'lib/loupe/queue_server.rb', line 35 def pop @queue.pop end |