Class: GorgonBunny::Concurrent::ContinuationQueue

Inherits:
Object
  • Object
show all
Defined in:
lib/gorgon_bunny/lib/gorgon_bunny/concurrent/continuation_queue.rb

Overview

Continuation queue implementation for MRI and Rubinius

Instance Method Summary collapse

Constructor Details

#initialize(*args, &block) ⇒ ContinuationQueue

Returns a new instance of ContinuationQueue.



9
10
11
# File 'lib/gorgon_bunny/lib/gorgon_bunny/concurrent/continuation_queue.rb', line 9

def initialize(*args, &block)
  @q = ::Queue.new(*args)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(selector, *args, &block) ⇒ Object



36
37
38
# File 'lib/gorgon_bunny/lib/gorgon_bunny/concurrent/continuation_queue.rb', line 36

def method_missing(selector, *args, &block)
  @q.__send__(selector, *args, &block)
end

Instance Method Details

#clearObject



32
33
34
# File 'lib/gorgon_bunny/lib/gorgon_bunny/concurrent/continuation_queue.rb', line 32

def clear
  @q.clear
end

#poll(timeout_in_ms = nil) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/gorgon_bunny/lib/gorgon_bunny/concurrent/continuation_queue.rb', line 22

def poll(timeout_in_ms = nil)
  if timeout_in_ms
    GorgonBunny::Timeout.timeout(timeout_in_ms / 1000, ::Timeout::Error) do
      @q.pop
    end
  else
    @q.pop
  end
end

#popObject



18
19
20
# File 'lib/gorgon_bunny/lib/gorgon_bunny/concurrent/continuation_queue.rb', line 18

def pop
  @q.pop
end

#push(*args) ⇒ Object Also known as: <<



13
14
15
# File 'lib/gorgon_bunny/lib/gorgon_bunny/concurrent/continuation_queue.rb', line 13

def push(*args)
  @q.push(*args)
end