Class: Loupe::QueueServer

Inherits:
Object
  • Object
show all
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

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

Parameters:



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

Parameters:



30
31
32
# File 'lib/loupe/queue_server.rb', line 30

def add_reporter(other)
  @reporter << other
end

#empty?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/loupe/queue_server.rb', line 45

def empty?
  @queue.empty?
end

#lengthInteger

Returns:

  • (Integer)


40
41
42
# File 'lib/loupe/queue_server.rb', line 40

def length
  @queue.length
end

#popArray<Class, Symbol>

Returns:

  • (Array<Class, Symbol>)


35
36
37
# File 'lib/loupe/queue_server.rb', line 35

def pop
  @queue.pop
end