Class: Ffmprb::Util::ThreadedIoBuffer::Stats
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Ffmprb::Util::ThreadedIoBuffer::Stats
- Includes:
- MonitorMixin
- Defined in:
- lib/ffmprb/util/threaded_io_buffer.rb
Instance Method Summary collapse
- #add_bytes_in(n) ⇒ Object
- #add_bytes_out(n) ⇒ Object
- #blocks_for(outp) ⇒ Object
-
#initialize(proc) ⇒ Stats
constructor
A new instance of Stats.
Constructor Details
#initialize(proc) ⇒ Stats
Returns a new instance of Stats.
300 301 302 303 304 |
# File 'lib/ffmprb/util/threaded_io_buffer.rb', line 300 def initialize(proc) @proc = proc @output_blocks = {} super blocks_buff: 0, blocks_max: 0, bytes_in: 0, bytes_out: 0 end |
Instance Method Details
#add_bytes_in(n) ⇒ Object
306 307 308 309 310 311 |
# File 'lib/ffmprb/util/threaded_io_buffer.rb', line 306 def add_bytes_in(n) synchronize do self.bytes_in += n @proc.proc_vis_node @proc # NOTE update end end |
#add_bytes_out(n) ⇒ Object
313 314 315 316 317 318 |
# File 'lib/ffmprb/util/threaded_io_buffer.rb', line 313 def add_bytes_out(n) synchronize do self.bytes_out += n @proc.proc_vis_node @proc # NOTE update end end |
#blocks_for(outp) ⇒ Object
320 321 322 323 324 325 326 327 328 329 |
# File 'lib/ffmprb/util/threaded_io_buffer.rb', line 320 def blocks_for(outp) synchronize do blocks = @output_blocks[outp.object_id] = outp.q.length if blocks > blocks_max self.blocks_max = blocks @proc.proc_vis_node @proc # NOTE update end self.blocks_buff = @output_blocks.values.reduce(0, :+) end end |