Class: CZTop::Z85::Pipe::Strategy::Parallel
- Inherits:
-
CZTop::Z85::Pipe::Strategy
- Object
- CZTop::Z85::Pipe::Strategy
- CZTop::Z85::Pipe::Strategy::Parallel
- Defined in:
- lib/cztop/z85/pipe.rb
Overview
Uses three threads:
-
reads from source
-
encodes/decodes
-
writes to sink
This might give a performance increase on truly parallel platforms such as Rubinius and JRuby (and multiple CPU cores).
Instance Method Summary collapse
-
#execute ⇒ Object
Runs the algorithm.
-
#initialize ⇒ Parallel
constructor
Initializes the 2 sized queues used.
Constructor Details
#initialize ⇒ Parallel
Initializes the 2 sized queues used.
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/cztop/z85/pipe.rb', line 128 def initialize(*) super # @source # | # V @source_queue = SizedQueue.new(20) # limit memory usage # | # V # xcode # | # V @sink_queue = SizedQueue.new(20) # limit memory usage # | # V # @sink end |
Instance Method Details
#execute ⇒ Object
Runs the algorithm.
148 149 150 151 152 |
# File 'lib/cztop/z85/pipe.rb', line 148 def execute Thread.new { read } Thread.new { xcode } write end |