Skip to content

Commit

Permalink
Tidy up thread killing. Remove JRuby workaround.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Aug 23, 2020
1 parent f72d44b commit 573aab1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
4 changes: 3 additions & 1 deletion lib/listen/adapter/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ def self.usable?
private

def _stop
@run_thread.kill.join if (@run_thread ||= nil)
if thread = @run_thread
thread.kill.join
end
end

def _timed(title)
Expand Down
12 changes: 3 additions & 9 deletions lib/listen/adapter/linux.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,9 @@ def _dir_event?(event)
end

def _stop
@worker.close if (@worker ||= nil)

# You can't kill a thread that is doing a sysread in JRuby, so
# skip `join` and pray thread dies fast...
if RUBY_ENGINE == 'jruby'
@run_thread.kill if (@run_thread ||= nil)
else
super
end
@worker&.close

super
end
end
end
Expand Down

0 comments on commit 573aab1

Please sign in to comment.