Class: EM::BufferedChannel
- Inherits:
-
Channel
- Object
- Channel
- EM::BufferedChannel
- Defined in:
- lib/em/buffered_channel.rb
Overview
A subclass of EM::Channel that implements double buffering (using a circular array of arrays) to achieve higher packet rate.
The buffer size and the number of buffers are critical to achieving good performance, you may need to tune them.
Defined Under Namespace
Classes: BufferSet
Instance Method Summary collapse
-
#initialize ⇒ BufferedChannel
constructor
A new instance of BufferedChannel.
- #push(*items) ⇒ Object
Constructor Details
#initialize ⇒ BufferedChannel
Returns a new instance of BufferedChannel.
12 13 14 15 |
# File 'lib/em/buffered_channel.rb', line 12 def initialize super @buffer = BufferSet.new(2000, 200) end |
Instance Method Details
#push(*items) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/em/buffered_channel.rb', line 17 def push(*items) @buffer.push(*items) do |buf| EM.schedule do @subs.values.each do |s| begin buf.each do |i| s.call i end ensure buf.clear end end end end end |