Class: ProxyTest::SingletonQueue

Inherits:
Object
  • Object
show all
Defined in:
lib/proxytest/helpers/backend.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ SingletonQueue

Returns a new instance of SingletonQueue.



23
24
25
26
27
28
# File 'lib/proxytest/helpers/backend.rb', line 23

def initialize(opts={})
  @in_q  = Queue.new
  @out_q = Queue.new
  opts[:port] ||= ::ProxyTest::Config.backend_port
  spawn_reader(opts[:port])
end

Instance Attribute Details

#in_qObject (readonly)

Returns the value of attribute in_q.



29
30
31
# File 'lib/proxytest/helpers/backend.rb', line 29

def in_q
  @in_q
end

#out_qObject (readonly)

Returns the value of attribute out_q.



29
30
31
# File 'lib/proxytest/helpers/backend.rb', line 29

def out_q
  @out_q
end

Class Method Details

.getObject



16
17
18
19
# File 'lib/proxytest/helpers/backend.rb', line 16

def self.get
  # Helper to make what's going on more obvious
  @@instance
end

.new(*args) ⇒ Object



11
12
13
14
# File 'lib/proxytest/helpers/backend.rb', line 11

def self.new(*args)
  # Guarantees that only a single instance will exist
  @@instance ||= super(*args)
end

Instance Method Details

#deqObject



35
36
37
# File 'lib/proxytest/helpers/backend.rb', line 35

def deq
  out_q.deq
end

#enq(data) ⇒ Object



31
32
33
# File 'lib/proxytest/helpers/backend.rb', line 31

def enq(data)
  in_q.enq(data)
end

#join!Object



39
40
41
# File 'lib/proxytest/helpers/backend.rb', line 39

def join!
  @thread.join
end