Sha256: e3f58f668de0a45d3063676444b9ba477b479cf03189f9cdd821d3611f64899d

Contents?: true

Size: 309 Bytes

Versions: 3

Compression:

Stored size: 309 Bytes

Contents

require 'page_by_page/enum'

module PageByPage
  class MutexEnum < Enum

    def initialize from: 1, step: 1
      super
      @q = SizedQueue.new 10
      Thread.new do
        loop do
          @q << @enum.next
          sleep 0.1
        end
      end
    end

    def next
      @q.deq
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
page_by_page-0.1.13 lib/page_by_page/mutex_enum.rb
page_by_page-0.1.12 lib/page_by_page/mutex_enum.rb
page_by_page-0.1.11 lib/page_by_page/mutex_enum.rb