Skip to content

Commit

Permalink
Add a more detailed explanation of the helper thread signal variable
Browse files Browse the repository at this point in the history
  • Loading branch information
vasilmkd committed Sep 7, 2021
1 parent bd1e2fe commit ba3cfe1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions core/jvm/src/main/scala/cats/effect/unsafe/HelperThread.scala
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ private final class HelperThread(
* Signalling mechanism through which the [[WorkerThread]] which spawned this
* [[HelperThread]] signals that it has successfully exited the blocking code
* region and that this [[HelperThread]] should finalize.
*
* This atomic integer encodes a state machine with 3 states.
* Value 0: the thread is parked
* Value 1: the thread is unparked and executing fibers
* Value 2: the thread has been signalled to finish up and exit
*
* The thread is spawned in the running state.
*/
private[this] val signal: AtomicInteger = new AtomicInteger(1)

Expand Down

0 comments on commit ba3cfe1

Please sign in to comment.