World thread-safety
Whilst the initial purpose of this was to fix world-thread safety, this PR has rather devolved into a general bugfix PR as it's easier than creating several inter-dependent PRs. Sorry.
This is an attempt at ensuring peripherals/other Lua calls do not access the world from the Lua thread. I'm going to be honest, none of the fixes are especially elegant. I'm expecting several of the fixes to require some level of polling, which is a pain. Currently most peripherals implement ITickable so it's not the end of the world, but it'd be nice to reduce the number which do in the future.
Current progress of the PR:
- [x] Cache direction of modems. (see #410).
- [x] Cache turtle family. (see SquidDev-CC/CCTweaks#113).
- [x] Cache monitor's terminal and peripheral type.
- There's technically a race conditions in disk drives and the corresponding
IMediaprovider but I've been unable to actually cause it, so goodness knows. - Probably lots of other things I haven't come across yet.
I'd really appreciate any testing people could do, as there may be subtle differences in behaviour. Similarly, if people are aware of any other thread-unsafe accesses, do tell.
It's worth noting that some of these changes will probably become redundant in the 1.13 update as we'll probably want to split peripherals into their own separate classes. I still think it's worth getting this in before that though.
it's not the end of the world
If it causes a save corruption then, arguably, it is the end of that world. 🤣
I'll show myself off out...
As you may be able to tell, the monitor changes are slightly larger than anticipated. As the potential for breakage is larger, I'd recommend some serious testing before merging. We're currently using this on SwitchCraft, which caught a lot of the issues before they ended up in the PR.
If anyone's interested in helping test, please download from the CI server.
Whilst the last commits aren't strictly world/computer threading issues, but they fix various aspects about monitors and it was easier to bundle them here instead. I'm happy to revert them if inconvenient.
There's some other fixes I'd like to add at some point, but I'd like to confirm they work and are needed first.
Can one of the admins verify this patch?
For what it's worth, I've been running a fork with almost all of my PRs merged on a relatively popular server and not seen any issues (it's actually more stable thanks to this pr).
That being said, there's not really much point bumping PRs. Dan merges stuff when he has time. While it's a little infuriating seeing stuff just sit there, I don't think it's fair to keep pestering Dan either.
I don't remember adding this comment... I think my Jenkins server pulled them all and auto-commented. My bad.
Ahhh, that explains a lot. I was rather confused when I woke up this morning and there were ~30 PRs with the same comment!