Class: InParallel::BlankBindingParallelProxy
- Inherits:
- BasicObject
- Includes:
- Kernel
- Defined in:
- lib/in_parallel.rb
Overview
Proxy class used to wrap each method execution in a block and run it in parallel A block from Parallel.run_in_parallel is executed with a binding of an instance of this class
Instance Method Summary collapse
-
#initialize(obj) ⇒ BlankBindingParallelProxy
constructor
A new instance of BlankBindingParallelProxy.
-
#method_missing(method_sym, *args, &block) ⇒ Object
All methods within the block should show up as missing (unless defined in :Kernel).
Constructor Details
#initialize(obj) ⇒ BlankBindingParallelProxy
Returns a new instance of BlankBindingParallelProxy.
169 170 171 172 |
# File 'lib/in_parallel.rb', line 169 def initialize(obj) @object = obj @result_id = 0 end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_sym, *args, &block) ⇒ Object
All methods within the block should show up as missing (unless defined in :Kernel)
175 176 177 178 179 |
# File 'lib/in_parallel.rb', line 175 def method_missing(method_sym, *args, &block) out = ::InParallel._execute_in_parallel(method_sym) {@object.send(method_sym, *args, &block)} puts "Forked process for '#{method_sym}' - PID = '#{out[:pid]}'\n" out[:tmp_result] end |