Skip to content

Commit

Permalink
Use a synchronous ThreadLocalAction for killing other threads
Browse files Browse the repository at this point in the history
* That way we have a snapshot fo the currently-running fibers and avoid
  e.g. scheduling the action on 2 Fibers of the same thread. See the
  javadoc of Env#submitThreadLocal which say:
  > Already started synchronous actions will block on activation of a new thread.
* Also this means we don't throw the KillException until all
  currently-running fibers have reached the safepoint.
* Note that because of the throw this synchronous action will be exited
  quickly by all threads once all threads have reached the safepoint. So
  there is no concern about a nested safepoint or
  new threads staying blocked a long time.
* This was the only ThreadLocalAction which affects multiple Ruby Threads
  and was asynchronous.

(cherry picked from commit 3637300)
  • Loading branch information
eregon committed Apr 25, 2023
1 parent 1d46c68 commit 5444848
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ private void doKillOtherThreads() {

context.getSafepointManager().pauseAllThreadsAndExecute(
DummyNode.INSTANCE,
new SafepointAction("kill other threads for shutdown", predicate, true, false) {
new SafepointAction("kill other threads for shutdown", predicate, true, true) {
@Override
public void run(RubyThread rubyThread, Node currentNode) {
rubyThread.status = ThreadStatus.ABORTING;
Expand Down

0 comments on commit 5444848

Please sign in to comment.