Class: DTAS::Buffer
- Inherits:
-
Object
- Object
- DTAS::Buffer
- Defined in:
- lib/dtas/buffer.rb
Overview
pipe buffer management for -player
Defined Under Namespace
Modules: FiddleSplice, ReadWrite, Splice
Instance Attribute Summary collapse
-
#bytes_xfer ⇒ Object
Returns the value of attribute bytes_xfer.
-
#to_io ⇒ Object
readonly
call nread on this.
-
#wr ⇒ Object
readonly
processes (sources) should redirect to this.
Class Method Summary collapse
Instance Method Summary collapse
- #__dst_error(dst, e) ⇒ Object
-
#broadcast(targets, limit = nil) ⇒ Object
This will modify targets returns one of: - :wait_readable - subset of targets array for :wait_writable - some type of StandardError - nil.
- #buf_reset ⇒ Object
-
#close ⇒ Object
don't really close the pipes under normal circumstances, just clear data.
- #close! ⇒ Object
- #inflight ⇒ Object
-
#initialize ⇒ Buffer
constructor
A new instance of Buffer.
- #readable_iter {|_self, nil| ... } ⇒ Object
- #to_hsh ⇒ Object
Constructor Details
Instance Attribute Details
#bytes_xfer ⇒ Object
Returns the value of attribute bytes_xfer.
26 27 28 |
# File 'lib/dtas/buffer.rb', line 26 def bytes_xfer @bytes_xfer end |
#to_io ⇒ Object (readonly)
call nread on this
24 25 26 |
# File 'lib/dtas/buffer.rb', line 24 def to_io @to_io end |
#wr ⇒ Object (readonly)
processes (sources) should redirect to this
25 26 27 |
# File 'lib/dtas/buffer.rb', line 25 def wr @wr end |
Class Method Details
.load(hash) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/dtas/buffer.rb', line 34 def self.load(hash) buf = new if hash bs = hash["buffer_size"] and buf.buffer_size = bs end buf end |
Instance Method Details
#__dst_error(dst, e) ⇒ Object
46 47 48 49 |
# File 'lib/dtas/buffer.rb', line 46 def __dst_error(dst, e) warn "dropping #{dst.inspect} due to error: #{e.} (#{e.class})" dst.close end |
#broadcast(targets, limit = nil) ⇒ Object
This will modify targets returns one of:
-
:wait_readable
-
subset of targets array for :wait_writable
-
some type of StandardError
-
nil
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/dtas/buffer.rb', line 57 def broadcast(targets, limit = nil) case targets.size when 0 :ignore # this will pause decoders when 1 broadcast_one(targets, limit) else # infinity broadcast_inf(targets, limit) end end |
#buf_reset ⇒ Object
83 84 85 86 87 88 |
# File 'lib/dtas/buffer.rb', line 83 def buf_reset close! @bytes_xfer = 0 @to_io, @wr = DTAS::Pipe.new @wr.pipe_size = @buffer_size if @buffer_size end |
#close ⇒ Object
don't really close the pipes under normal circumstances, just clear data
78 79 80 81 |
# File 'lib/dtas/buffer.rb', line 78 def close bytes = inflight discard(bytes) if bytes > 0 end |
#close! ⇒ Object
90 91 92 93 |
# File 'lib/dtas/buffer.rb', line 90 def close! @to_io.close @wr.close end |
#inflight ⇒ Object
73 74 75 |
# File 'lib/dtas/buffer.rb', line 73 def inflight @to_io.nread end |
#readable_iter {|_self, nil| ... } ⇒ Object
68 69 70 71 |
# File 'lib/dtas/buffer.rb', line 68 def readable_iter # this calls DTAS::Buffer#broadcast from DTAS::Player yield(self, nil) end |
#to_hsh ⇒ Object
42 43 44 |
# File 'lib/dtas/buffer.rb', line 42 def to_hsh @buffer_size ? { "buffer_size" => @buffer_size } : {} end |