Merged
Conversation
This change modifies our shutdown process to asynchronously interrupt and wait for all registered threads (excluding main) to allow them to complete execution. Previously our behavior was to walk away from running threads. This behavior appears to have either changed in CRuby long ago, or we never implemented this behavior. Note that this implementation does not differentiate between threads started from Ruby code and threads started by other code in the JVM that happened to get adopted by JRuby. We probably should not attempt to kill those adopted threads, and certainly don't want to try to join on them.
This marks all thread created outside of JRuby as "adopted", meaning that their lifecycles exist outside the lifecycle of the JRuby runtime. At runtime teardown, only non-adopted threads with lifecycles tied to the runtime will be terminated.
2da902a to
1b0d8d4
Compare
Member
Author
|
Note a few issues reference our non-shutdown of running threads:
|
Member
Author
|
Reviewed by @enebo with no major concerns. We'll merge and let this bake. There's one additional change I considered and rejected: don't shut down all threads if we're not the "main" runtime (i.e. check the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change modifies our shutdown process to asynchronously interrupt and wait for all registered threads (excluding main) to allow them to complete execution.
Previously our behavior was to walk away from running threads. This behavior appears to have either changed in CRuby long ago, or we never implemented this behavior.
Note that this implementation does not currently differentiate between threads started from Ruby code and threads started by other code in the JVM that happened to get adopted by JRuby. We probably should not attempt to kill those adopted threads, and certainly don't want to try to join on them.
The following script illustrates some behavior of thread shutdown. This may be a good start at writing a spec.