Class: Ffmprb::Util::ThreadedIoBuffer

Inherits:
Object
  • Object
show all
Defined in:
lib/ffmprb/util/threaded_io_buffer.rb

Overview

TODO the events mechanism is currently unused (and commented out) => synchro mechanism not needed XXX partially specc’ed in file_spec

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input, *outputs) ⇒ ThreadedIoBuffer

NOTE input/output can be lambdas for single asynchronic io evaluation

the labdas must be timeout-interrupt-safe (since they are wrapped in timeout blocks)

NOTE both ios are being opened and closed as soon as possible



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/ffmprb/util/threaded_io_buffer.rb', line 25

def initialize(input, *outputs)  # XXX SPEC ME!!! multiple outputs!!

  @input = input
  @outputs = outputs.inject({}) do |hash, out|
    hash[out] = SizedQueue.new(self.class.blocks_max)
    hash
  end
  @stat_blocks_max = 0
  @terminate = false
  # @events = {}

  Thread.new "io buffer main" do
    init_reader!
    outputs.each do |output|
      init_writer_output! output
      init_writer! output
    end

    Thread.join_children!
  end
end

Class Attribute Details

.block_sizeObject

Returns the value of attribute block_size.



13
14
15
# File 'lib/ffmprb/util/threaded_io_buffer.rb', line 13

def block_size
  @block_size
end

.blocks_maxObject

Returns the value of attribute blocks_max.



12
13
14
# File 'lib/ffmprb/util/threaded_io_buffer.rb', line 12

def blocks_max
  @blocks_max
end

.timeoutObject

Returns the value of attribute timeout.



14
15
16
# File 'lib/ffmprb/util/threaded_io_buffer.rb', line 14

def timeout
  @timeout
end

Class Method Details

.default_sizeObject



16
17
18
# File 'lib/ffmprb/util/threaded_io_buffer.rb', line 16

def default_size
  blocks_max * block_size
end