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.
303 304 305 306 307 |
# File 'lib/ffmprb/util/threaded_io_buffer.rb', line 303 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
309 310 311 312 313 314 |
# File 'lib/ffmprb/util/threaded_io_buffer.rb', line 309 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
316 317 318 319 320 321 |
# File 'lib/ffmprb/util/threaded_io_buffer.rb', line 316 def add_bytes_out(n) synchronize do self.bytes_out += n @proc.proc_vis_node @proc # NOTE update end end |
#blocks_for(outp) ⇒ Object
323 324 325 326 327 328 329 330 331 332 |
# File 'lib/ffmprb/util/threaded_io_buffer.rb', line 323 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 |