Sha256: b7c90ebee62f31d4db13258afc70394d4e7dd3a840c434350f93cf322e9b6953

Contents?: true

Size: 742 Bytes

Versions: 20

Compression:

Stored size: 742 Bytes

Contents

require "thread"

module Bunny
  module Concurrent
    # Continuation queue implementation for MRI and Rubinius
    #
    # @private
    class ContinuationQueue
      def initialize(*args, &block)
        @q = ::Queue.new(*args)
      end

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

      def pop
        @q.pop
      end

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

      def clear
        @q.clear
      end

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

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
bunny-0.10.4 lib/bunny/concurrent/continuation_queue.rb
bunny-0.10.3 lib/bunny/concurrent/continuation_queue.rb
bunny-1.0.0.pre4 lib/bunny/concurrent/continuation_queue.rb
bunny-0.10.2 lib/bunny/concurrent/continuation_queue.rb
bunny-0.10.1 lib/bunny/concurrent/continuation_queue.rb
bunny-0.10.0 lib/bunny/concurrent/continuation_queue.rb
bunny-1.0.0.pre3 lib/bunny/concurrent/continuation_queue.rb
bunny-0.9.8 lib/bunny/concurrent/continuation_queue.rb
bunny-1.0.0.pre2 lib/bunny/concurrent/continuation_queue.rb
bunny-0.9.7 lib/bunny/concurrent/continuation_queue.rb
bunny-0.9.6 lib/bunny/concurrent/continuation_queue.rb
bunny-0.9.5 lib/bunny/concurrent/continuation_queue.rb
bunny-0.9.4 lib/bunny/concurrent/continuation_queue.rb
bunny-1.0.0.pre1 lib/bunny/concurrent/continuation_queue.rb
bunny-0.9.3 lib/bunny/concurrent/continuation_queue.rb
bunny-0.9.2 lib/bunny/concurrent/continuation_queue.rb
bunny-0.9.1 lib/bunny/concurrent/continuation_queue.rb
bunny-0.9.0 lib/bunny/concurrent/continuation_queue.rb
bunny-0.9.0.rc2 lib/bunny/concurrent/continuation_queue.rb
bunny-0.9.0.rc1 lib/bunny/concurrent/continuation_queue.rb