T
twostars
Improve thread shutdown logic
Rename _running to _canTick and add _isShutdown to explicitly separate behaviour.
That is, before, a thread could no longer be running, but not yet be shutdown (i.e. the thread is technically still running).
Now a thread can continue to tick for as long as _canTick is set, but it's not until _isShutdown is set that the thread has actually finally finished running.
Additionally, ensure we always join() (when requested) on shutdown(). This ensures that if the thread was externally shutdown, we still wait for it to do so,
rather than just immediately returning.
Finally, add some error handling for join().
Github Commit Görüntüle...
See Commints...
..
Rename _running to _canTick and add _isShutdown to explicitly separate behaviour.
That is, before, a thread could no longer be running, but not yet be shutdown (i.e. the thread is technically still running).
Now a thread can continue to tick for as long as _canTick is set, but it's not until _isShutdown is set that the thread has actually finally finished running.
Additionally, ensure we always join() (when requested) on shutdown(). This ensures that if the thread was externally shutdown, we still wait for it to do so,
rather than just immediately returning.
Finally, add some error handling for join().
Github Commit Görüntüle...
See Commints...
..