Class: InParallel::InParallelExecutor::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.
240 241 242 243 |
# File 'lib/in_parallel.rb', line 240 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)
246 247 248 249 250 251 252 |
# File 'lib/in_parallel.rb', line 246 def method_missing(method_sym, *args, &block) if InParallelExecutor.main_pid == ::Process.pid out = InParallelExecutor._execute_in_parallel("'#{method_sym.to_s}' #{caller_locations[0].to_s}", @object.eval('self')) {send(method_sym, *args, &block)} puts "Forked process for '#{method_sym}' - PID = '#{out[:pid]}'\n" out[:tmp_result] end end |