Sha256: 49b636f331b6e2e818ea8896e995aba38449b066a3d3864f7cc32b4c6ee536d5

Contents?: true

Size: 728 Bytes

Versions: 1

Compression:

Stored size: 728 Bytes

Contents

class Datapipes
  # Pipe is not only data pipeline but handling asynchronous.
  #
  # You can make your own pipe with database or something, but
  # becareful this object used in multi thread.
  #
  # If you make your own, you can override _initialize_, because
  # this is not used in internal.
  #
  # Then supply _pour_in_ and _pour_out_. _pour_out_ must occur
  # thread blocking when it is empty.
  class Pipe
    # You can override and don't need to call super in sub class.
    def initialize
      @queue ||= Queue.new
    end

    # Emit data to pipe.
    def pour_in(data)
      @queue.enq data
    end

    # _pour_out_ must cause thread blocking when it is empty.
    def pour_out
      @queue.deq
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
datapipes-0.1.5 lib/datapipes/pipe.rb