Class: EM::BufferedChannel::BufferSet
- Inherits:
-
Object
- Object
- EM::BufferedChannel::BufferSet
- Defined in:
- lib/em/buffered_channel.rb
Instance Method Summary collapse
-
#initialize(size, nbufs) ⇒ BufferSet
constructor
A new instance of BufferSet.
- #push(data) ⇒ Object
Constructor Details
#initialize(size, nbufs) ⇒ BufferSet
Returns a new instance of BufferSet.
34 35 36 37 38 39 40 41 |
# File 'lib/em/buffered_channel.rb', line 34 def initialize(size, nbufs) @size = size @nbufs = nbufs @buffers = [] setup end |
Instance Method Details
#push(data) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/em/buffered_channel.rb', line 43 def push(data) raise "WTF #{@buffers.length}" unless @buffers.length == @nbufs if @buffers[0].length > @size if @buffers[1].length > 0 raise "panic! the next buffer is still full!" end buf = @buffers.shift @buffers << buf yield buf end @buffers.first << data end |