Further process tweaks

- Integrates Volundr's btime library and associated process scheduler
changes.
- btime is implemented separately from the process scheduler, as precise
time measurement is also useful elsewhere.
- `TimeOfHour` is no longer internally throttled; throttling is instead
done by `SCHECK`.
- If btime's `gettime` cannot be called at world startup, an error will
be output and the world will stop.
- Retains the change to schedule processes according to game time,
rather than real time.
- Removes the (now unused) update queue files.
- Removes the process scheduler testing files.
- These are standalone tests for the process scheduler, completely
unrelated to its use in the full codebase. We never used them.
- Moves the process scheduler defines into __DEFINES.
- Makes the lighting process run once before the round starts.
- Renames `scheck` to `sleepCheck`, to ensure any code that tries to use
`scheck` will fail to compile.
- Adds `SCHECK` and `SCHECK_EVERY` macros that skip calling `sleepCheck`
entirely until a specified number of `SCHECK`s (50 by default) have been
called.
- Makes most processes iterate using their `last_object` variable,
allowing hang recovery to show the type that caused the hang.
- Makes processes output an error when they filter out a type they
refuse to process.
- Rolls the recently-added alarm subsystem into the alarm process.
- Removes the now unused subsystems code.
This commit is contained in:
Krausus
2015-08-08 09:07:26 -04:00
parent 26d35be764
commit 61edb3eb95
35 changed files with 255 additions and 951 deletions
+6 -6
View File
@@ -54,27 +54,27 @@ var/global/datum/controller/process/air_system/air_master
last_hotspots = hotspots.len
for(var/obj/effect/hotspot/H in hotspots)
H.process()
scheck()
SCHECK
/datum/controller/process/air_system/proc/process_super_conductivity()
last_asc = active_super_conductivity.len
for(var/turf/simulated/T in active_super_conductivity)
T.super_conduct()
scheck()
SCHECK
/datum/controller/process/air_system/proc/process_high_pressure_delta()
last_hpd = high_pressure_delta.len
for(var/turf/T in high_pressure_delta)
T.high_pressure_movements()
T.pressure_difference = 0
scheck()
SCHECK
high_pressure_delta.Cut()
/datum/controller/process/air_system/proc/process_active_turfs()
last_active = active_turfs.len
for(var/turf/simulated/T in active_turfs)
T.process_cell()
scheck()
SCHECK
/datum/controller/process/air_system/proc/remove_from_active(var/turf/simulated/T)
if(istype(T))
@@ -123,11 +123,11 @@ var/global/datum/controller/process/air_system/air_master
EG.breakdown_cooldown ++
if(EG.breakdown_cooldown == 10)
EG.self_breakdown()
scheck()
SCHECK
return
if(EG.breakdown_cooldown > 20)
EG.dismantle()
scheck()
SCHECK
/datum/controller/process/air_system/proc/setup_overlays()
plmaster = new /obj/effect/overlay()
+30 -1
View File
@@ -1,6 +1,35 @@
// We manually initialize the alarm handlers instead of looping over all existing types
// to make it possible to write: camera.triggerAlarm() rather than alarm_manager.managers[datum/alarm_handler/camera].triggerAlarm() or a variant thereof.
/var/global/datum/alarm_handler/atmosphere/atmosphere_alarm = new()
/var/global/datum/alarm_handler/camera/camera_alarm = new()
/var/global/datum/alarm_handler/fire/fire_alarm = new()
/var/global/datum/alarm_handler/motion/motion_alarm = new()
/var/global/datum/alarm_handler/power/power_alarm = new()
// Alarm Manager, the manager for alarms.
var/datum/controller/process/alarm/alarm_manager
/datum/controller/process/alarm
var/list/datum/alarm/all_handlers
/datum/controller/process/alarm/setup()
name = "alarm"
schedule_interval = 20 // every 2 seconds
all_handlers = list(atmosphere_alarm, camera_alarm, fire_alarm, motion_alarm, power_alarm)
alarm_manager = src
/datum/controller/process/alarm/doWork()
alarm_manager.fire()
for(var/datum/alarm_handler/AH in all_handlers)
AH.process()
/datum/controller/process/alarm/proc/active_alarms()
var/list/all_alarms = new
for(var/datum/alarm_handler/AH in all_handlers)
var/list/alarms = AH.alarms
all_alarms += alarms
return all_alarms
/datum/controller/process/alarm/proc/number_of_active_alarms()
var/list/alarms = active_alarms()
return alarms.len
+5 -6
View File
@@ -1,5 +1,3 @@
/datum/controller/process/bot
/datum/controller/process/bot/setup()
name = "bot"
schedule_interval = 20 // every 2 seconds
@@ -14,7 +12,8 @@
stat(null, "[aibots && aibots.len] bots")
/datum/controller/process/bot/doWork()
for(var/obj/machinery/bot/B in aibots)
for(last_object in aibots)
var/obj/machinery/bot/B = last_object
if(istype(B) && isnull(B.gcDestroyed))
// Some bots sleep when they process, but there's not many bots, so just spawn them off
spawn(-1)
@@ -22,7 +21,7 @@
B.bot_process()
catch(var/exception/e)
catchException(e, B)
// Use src explicitly after a try/catch, or BYOND messes src up. I have no idea why.
src.scheck()
SCHECK
else
aibots -= B
catchBadType(B)
aibots -= B
+1 -1
View File
@@ -11,6 +11,6 @@
C << "<SPAN CLASS='warning'>You have been inactive for more than 10 minutes and have been disconnected.</SPAN>"
del(C)
scheck()
SCHECK
#undef INACTIVITY_KICK*/
+3
View File
@@ -7,6 +7,9 @@ var/global/datum/controller/process/lighting/lighting_controller
lighting_controller = src
create_lighting_overlays()
// Pre-process lighting once before the round starts. Wait 30 seconds so the away mission has time to load.
spawn(300)
doWork()
/datum/controller/process/lighting/statProcess()
..()
+11 -10
View File
@@ -19,22 +19,22 @@
/datum/controller/process/machinery/proc/process_sort()
if(machinery_sort_required)
machinery_sort_required = 0
machines = dd_sortedObjectList(machines)
machines = dd_sortedObjectList(machines)
/datum/controller/process/machinery/proc/process_machines()
for(var/obj/machinery/M in machines)
if(M && isnull(M.gcDestroyed))
for(last_object in machines)
var/obj/machinery/M = last_object
if(istype(M) && isnull(M.gcDestroyed))
#ifdef PROFILE_MACHINES
var/time_start = world.timeofday
#endif
try
if(M.process() == PROCESS_KILL)
//M.inMachineList = 0 We don't use this debugging function
machines.Remove(M)
continue
if(M && M.use_power)
if(M.use_power)
M.auto_use_power()
catch(var/exception/e)
catchException(e, M)
@@ -48,19 +48,20 @@
machine_profiling[M.type] += (time_end - time_start)
#endif
else
catchBadType(M)
machines -= M
scheck()
SCHECK_EVERY(100)
/datum/controller/process/machinery/proc/process_power()
for(var/datum/powernet/powerNetwork in powernets)
for(last_object in powernets)
var/datum/powernet/powerNetwork = last_object
if(istype(powerNetwork) && isnull(powerNetwork.gcDestroyed))
try
powerNetwork.reset()
catch(var/exception/e)
catchException(e, powerNetwork)
// Use src explicitly after a try/catch, or BYOND messes src up. I have no idea why.
src.scheck()
SCHECK
continue
powernets.Remove(powerNetwork)
@@ -70,4 +71,4 @@
for(var/obj/item/I in processing_power_items)
if(!I.pwr_drain()) // 0 = Process Kill, remove from processing list.
processing_power_items.Remove(I)
scheck()
SCHECK
+4 -3
View File
@@ -18,15 +18,16 @@
stat(null, "[mob_list.len] mobs")
/datum/controller/process/mob/doWork()
for(var/mob/M in mob_list)
for(last_object in mob_list)
var/mob/M = last_object
if(istype(M) && isnull(M.gcDestroyed))
try
M.Life()
catch(var/exception/e)
catchException(e, M)
// Use src explicitly after a try/catch, or BYOND messes src up. I have no idea why.
src.scheck()
SCHECK
else
catchBadType(M)
mob_list -= M
mob_master.process()
+3 -3
View File
@@ -1,5 +1,3 @@
/datum/controller/process/nanoui
/datum/controller/process/nanoui/setup()
name = "nanoui"
schedule_interval = 20 // every 2 seconds
@@ -9,11 +7,13 @@
stat(null, "[nanomanager.processing_uis.len] UIs")
/datum/controller/process/nanoui/doWork()
for(var/datum/nanoui/NUI in nanomanager.processing_uis)
for(last_object in nanomanager.processing_uis)
var/datum/nanoui/NUI = last_object
if(istype(NUI) && isnull(NUI.gcDestroyed))
try
NUI.process()
catch(var/exception/e)
catchException(e, NUI)
else
catchBadType(NUI)
nanomanager.processing_uis -= NUI
+8 -8
View File
@@ -1,6 +1,3 @@
var/global/list/object_profiling = list()
/datum/controller/process/obj
/datum/controller/process/obj/setup()
name = "obj"
schedule_interval = 20 // every 2 seconds
@@ -16,13 +13,16 @@ var/global/list/object_profiling = list()
stat(null, "[processing_objects.len] objects")
/datum/controller/process/obj/doWork()
for(var/obj/O in processing_objects)
for(last_object in processing_objects)
var/datum/O = last_object
if(istype(O) && isnull(O.gcDestroyed))
try
O.process()
// Reagent datums get shoved in here, but the process proc isn't on the
// base datum type, so we just call it blindly.
O:process()
catch(var/exception/e)
catchException(e, O)
// Use src explicitly after a try/catch, or BYOND messes src up. I have no idea why.
src.scheck()
SCHECK
else
processing_objects -= O
catchBadType(O)
processing_objects -= O
+4 -3
View File
@@ -8,14 +8,15 @@
stat(null, "[pipe_networks.len] pipe nets")
/datum/controller/process/pipenet/doWork()
for(var/datum/pipe_network/pipeNetwork in pipe_networks)
for(last_object in pipe_networks)
var/datum/pipe_network/pipeNetwork = last_object
if(istype(pipeNetwork) && isnull(pipeNetwork.gcDestroyed))
try
pipeNetwork.process()
catch(var/exception/e)
catchException(e, pipeNetwork)
// Use src explicitly after a try/catch, or BYOND messes src up. I have no idea why.
src.scheck()
SCHECK
continue
else
catchBadType(pipeNetwork)
pipe_networks -= pipeNetwork
+14 -5
View File
@@ -44,8 +44,17 @@ var/global/datum/controller/process/sun/sun
//now tell the solar control computers to update their status and linked devices
/datum/controller/process/sun/proc/update_solar_machinery()
for(var/obj/machinery/power/solar_control/SC in solars)
if(!SC.powernet)
solars.Remove(SC)
continue
SC.update()
for(last_object in solars)
var/obj/machinery/power/solar_control/SC = last_object
if(istype(SC) && isnull(SC.gcDestroyed))
if(!SC.powernet)
solars -= SC
continue
try
SC.update()
catch(var/exception/e)
catchException(e, SC)
SCHECK
else
catchBadType(SC)
solars -= SC