PocketMine-MP
PocketMine-MP copied to clipboard
Remove `ThreadManager`
Description
The only remaining uses for ThreadManager are:
- Providing thread count - inaccurate if threads start more threads, can be better provided by
ext-pmmpthreaddirectly - Stopping threads which haven't stopped themselves - mostly pointless
- threads will join themselves when
__destruct()'d under normal circumstances, which ThreadManager actually interferes with by keeping strong references - on-shutdown thread stopping can be implemented by overriding
join()which will be called directly byext-pmmpthreadduring__destruct()
- threads will join themselves when
- Simulating
detach()and/or leaking threads - not a particularly useful case, and can also be simulated more intentionally by implementingdetach()inext-pmmpthreaddirectly - Delaying automatic attempts to stop threads to allow
ServerKillerfunctionality to work - not sure how to replace or remove this
In addition:
- Even if it did track threads started by other threads, we wouldn't actually want ThreadManager to try and stop them, because the parent of a thread can't be
join()'d before its children are alsojoin()'d. At best we would want to stop them in reverse order, which it's never done.
TL;DR: ThreadManager no longer serves a useful purpose, and is actually probably detrimental in some cases.