mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-12-25 01:20:31 +00:00
0929ab577d
This is an attempt to enforce better separation between ComputerThread and ComputerExecutor. Both of these classes are pretty complex in their own right, and the way the two bleed into each other makes it all the more confusing! This effectively splits the ComputerExecutor into two separate classes: - ComputerScheduler.Executor (with the actual implementation inside ComputerThread): This holds all the ComputerThread-related logic which used to be in ComputerExecutor, including: - before/after work hooks - is-on-thread tracking - virtual runtime computation - ComputerScheduler.Worker: This encapsulates all the computer-related behaviour. The actual implementation remains in ComputerExecutor. The boundaries are still a little fuzzy here, and it's all definitely more coupled then I'd like, but still an improvement! There are several additional changes at the same time: - TimeoutState has also been split up, to better define the boundary between consumers (such as ComputerExecutor and ILuaMachine) and controllers (ComputerThread). The getters still live in TimeoutState, but the core logic lives in ManagedTimeoutState. - We no longer track cumulative time in the TimeoutState. Instead, we allow varying the timeout of a computer. When a computer is paused, we store the remaining time, and restore it when resuming again. This also allows us give a longer timeout for computer startup/shutdown, hopefully avoiding some of those class-not-found issues we've seen. - We try to make the state machine of how ComputerExecutors live on the queue a little more explicit. This is very messy/confusing - something I want to property test in the future. I'm sure there's more to be done here, especially in ComputerExecutor, but hopefully this makes future changes a little less intimidating. |
||
---|---|---|
.. | ||
checkstyle | ||
gitpod |