Class: Pthread::PthreadExecutor
- Inherits:
-
Object
- Object
- Pthread::PthreadExecutor
- Defined in:
- lib/pthread/pthread_executor.rb
Instance Method Summary collapse
-
#initialize(host, queue = nil) ⇒ PthreadExecutor
constructor
A new instance of PthreadExecutor.
Constructor Details
#initialize(host, queue = nil) ⇒ PthreadExecutor
Returns a new instance of PthreadExecutor.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/pthread/pthread_executor.rb', line 4 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 |