Class: Eventbox::Thread

Inherits:
Thread
  • Object
show all
Defined in:
lib/eventbox.rb

Overview

This is a workaround for bug github.com/jruby/jruby/issues/5314 which was fixed in JRuby-9.2.1.0.

Instance Method Summary collapse

Constructor Details

#initialize(*args, &block) ⇒ Thread

Returns a new instance of Thread.



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/eventbox.rb', line 27

def initialize(*args, &block)
  started = Queue.new
  super do
    Thread.handle_interrupt(Exception => :never) do
      started << true
      block.call(*args)
      # Immediately stop the thread, before the handle_interrupt has finished.
      # This is necessary for JRuby to avoid possoble signal handling after the block.
      Thread.exit
    end
  end
  started.pop
end