Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Listen::Internals::ThreadPool #483

Merged
merged 1 commit into from
Aug 23, 2020
Merged

Remove Listen::Internals::ThreadPool #483

merged 1 commit into from
Aug 23, 2020

Conversation

ioquatix
Copy link
Member

Listen::Internals::ThreadPool manages all listener threads. Thus the
only way to kill and subsequently garbage collect listener threads is by
calling the Listen::Internals::ThreadPool.stop method (typically done
via Listen.stop). This is a problem when individual listeners must be
stopped and abandoned for garbage collection.

This commit removes Listen::Internals::ThreadPool in favor of listener
instances managing their own threads.

Partially addresses #476.

`Listen::Internals::ThreadPool` manages all listener threads.  Thus the
only way to kill and subsequently garbage collect listener threads is by
calling the `Listen::Internals::ThreadPool.stop` method (typically done
via `Listen.stop`).  This is a problem when individual listeners must be
stopped and abandoned for garbage collection.

This commit removes `Listen::Internals::ThreadPool` in favor of listener
instances managing their own threads.

Partially addresses #476.
@ioquatix ioquatix merged commit f72d44b into master Aug 23, 2020
@@ -96,6 +96,7 @@ def self.usable?
private

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/ParenthesesAroundCondition: Don't use parentheses around the condition of an if.

@@ -74,6 +73,11 @@ def _run_worker(worker)
format_string = 'fsevent: running worker failed: %s:%s called from: %s'
_log_exception format_string, caller
end

def _stop
@worker_thread.kill.join if (@worker_thread ||= nil)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/ParenthesesAroundCondition: Don't use parentheses around the condition of an if.

# 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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/ParenthesesAroundCondition: Don't use parentheses around the condition of an if.

@@ -99,7 +97,15 @@ def _dir_event?(event)
end

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/ParenthesesAroundCondition: Don't use parentheses around the condition of an if.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants