Class: Pthread::PthreadExecutor
- Inherits:
-
Object
- Object
- Pthread::PthreadExecutor
- Defined in:
- lib/pthread/pthread_executor.rb
Overview
PthreadExecutor
is used by Pthread to run code in a separate fork. Users can you this class to start executors manually on remote machines.
Instance Method Summary collapse
-
#initialize(host, queue = nil) ⇒ PthreadExecutor
constructor
Initliazes new executor.
Constructor Details
#initialize(host, queue = nil) ⇒ PthreadExecutor
Initliazes new executor.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/pthread/pthread_executor.rb', line 16 def initialize(host, queue=nil) DRb.start_service ts = DRbObject.new_with_uri("druby://#{host}") loop do pthread_id, _, code, context = ts.take([nil, queue, nil, nil]) context && context.each do |a, v| singleton_class.class_eval { attr_accessor a } self.send("#{a}=", context[a]) end value = begin eval(code) rescue => e e end ts.write([pthread_id, value]) end rescue DRb::DRbConnError exit 0 end |