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

Constructor Details

#initialize(obj) ⇒ BlankBindingParallelProxy

Returns a new instance of BlankBindingParallelProxy.



312
313
314
315
# File 'lib/in_parallel.rb', line 312

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)



318
319
320
321
322
323
324
# File 'lib/in_parallel.rb', line 318

def method_missing(method_sym, *args, &block)
  if InParallelExecutor.main_pid == ::Process.pid
    out = InParallelExecutor._execute_in_parallel("'#{method_sym.to_s}' #{caller[0].to_s}",
                                                  @object.eval('self')) { send(method_sym, *args, &block) }
    out[:tmp_result]
  end
end