Project

General

Profile

Actions

Feature #15909

open

Improve Thread#exit documentation

Added by womble (Matt Palmer) over 5 years ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:93028]

Description

Whilst writing some low-level threading code, I came across a couple of unexpected (though useful) behaviours of Thread#exit (aka #kill, #terminate) that I think are worth documenting for the benefit of future generations. Attached is my attempt to write that documentation. Further, I found what I think are some inaccuracies in the existing documentation for Thread#exit, so I attempted to fix those, too.

Detailed rationale for each change, in order of their appearance in the patch:

  • As far as I can see, all return calls return thread, and thread is never mutated, so I can't see a way nil could ever be returned.
  • The thread is not actually terminated by this method; instead, it is merely marked to be terminated.
  • I can't find anywhere in the call tree that pokes the thread scheduler to run another thread.
  • ensure blocks being run, rather than the thread just immediately up and dying, was the first unexpected behaviour I came across.
  • Being able to defer termination via .handle_interrupt was the second unexpected behaviour I found.

Files

thread_kill_docs.patch (954 Bytes) thread_kill_docs.patch womble (Matt Palmer), 06/09/2019 12:05 AM

No data to display

Actions

Also available in: Atom PDF

Like0