subsystem changes (#5332)

1. de-tickers basically everything that doesn't need to be a ticker (so
most of them)
2. makes SSdpc not awful (thanks @Lohikar)

---------

Co-authored-by: silicons <no@you.cat>
This commit is contained in:
silicons
2023-04-09 18:35:20 -07:00
committed by GitHub
co-authored by silicons
parent dc0cf7a728
commit d76b535a65
10 changed files with 59 additions and 39 deletions
+32 -21
View File
@@ -1,26 +1,37 @@
/**
* delayed procedure call, equivalent to addtimer 0
*/
/*
This is pretty much just an optimization for wait=0 timers. They're relatively common, but generally don't actually need the more
complex features of SStimer. SSdpc can handle these timers instead (and it's a lot simpler than SStimer is), but it can't handle
complex timers with flags. This doesn't need to be explicitly used, eligible timers are automatically converted.
*/
SUBSYSTEM_DEF(dpc)
subsystem_flags = SS_NO_FIRE | SS_NO_INIT
name = "Delayed Procedure Call"
wait = 1
runlevels = RUNLEVELS_ALL
priority = FIRE_PRIORITY_DPC
subsystem_flags = SS_TICKER | SS_NO_INIT
/// are we queued?
var/primed = FALSE
/// targets - we do not check for qdels!
var/list/targets = list()
var/list/queued_calls = list()
var/list/avg = 0
/datum/controller/subsystem/dpc/proc/queue_invoke(datum/target, procpath/callpath, ...)
targets[++targets.len] = args.Copy()
if(!primed)
prime()
/datum/controller/subsystem/dpc/stat_entry()
return ..() + " Q: [queued_calls.len], AQ: ~[round(avg)]"
/datum/controller/subsystem/dpc/proc/prime()
ASSERT(!primed)
primed = TRUE
addtimer(CALLBACK(src, TYPE_PROC_REF(/datum/controller/subsystem/dpc, invoke_calls)), 0)
/datum/controller/subsystem/dpc/fire(resumed = FALSE)
var/list/qc = queued_calls
if (!resumed)
avg = MC_AVERAGE_FAST(avg, qc.len)
/datum/controller/subsystem/dpc/proc/invoke_calls()
primed = FALSE
for(var/list/targlist as anything in targets)
call(targlist[1], targlist[2])(arglist(targlist.Copy(3)))
targets.len = 0
var/q_idex = 1
while (q_idex <= qc.len)
var/datum/callback/CB = qc[q_idex]
q_idex += 1
CB.InvokeAsync()
if (MC_TICK_CHECK)
break
if (q_idex > 1)
queued_calls.Cut(1, q_idex)
+1 -1
View File
@@ -3,7 +3,7 @@ SUBSYSTEM_DEF(ai)
init_order = INIT_ORDER_AI
priority = FIRE_PRIORITY_AI
wait = 5 // This gets run twice a second, however this is technically two loops in one, with the second loop being run every four iterations.
subsystem_flags = SS_NO_INIT|SS_TICKER
subsystem_flags = SS_NO_INIT
runlevels = RUNLEVEL_GAME | RUNLEVEL_POSTGAME
var/list/processing = list()
+2 -2
View File
@@ -5,8 +5,8 @@
SUBSYSTEM_DEF(chat)
name = "Chat"
subsystem_flags = SS_TICKER
wait = 1
subsystem_flags = NONE
wait = 0.25 // scale up to 40 fps
priority = FIRE_PRIORITY_CHAT
init_order = INIT_ORDER_CHAT
+2 -2
View File
@@ -1,9 +1,9 @@
SUBSYSTEM_DEF(icon_smooth)
name = "Icon Smoothing"
init_order = INIT_ORDER_ICON_SMOOTHING
wait = 1
wait = 0.25 // scale up to 40 fps
priority = FIRE_PRIORITY_SMOOTHING
subsystem_flags = SS_TICKER
subsystem_flags = NONE
///Blueprints assemble an image of what pipes/manifolds/wires look like on initialization, and thus should be taken after everything's been smoothed
// var/list/blueprint_queue = list()
+2 -2
View File
@@ -1,8 +1,8 @@
SUBSYSTEM_DEF(input)
name = "Input"
wait = 1 //SS_TICKER means this runs every tick
wait = 0.25 // scale to 40 fps
init_order = INIT_ORDER_INPUT
subsystem_flags = SS_TICKER
subsystem_flags = NONE
priority = FIRE_PRIORITY_INPUT
runlevels = RUNLEVELS_DEFAULT | RUNLEVEL_LOBBY
@@ -1,9 +1,9 @@
PROCESSING_SUBSYSTEM_DEF(projectiles)
name = "Projectiles"
wait = 1
wait = 0.25 // scale up to 40 fps
stat_tag = "PP"
priority = FIRE_PRIORITY_PROJECTILES
subsystem_flags = SS_NO_INIT|SS_TICKER
subsystem_flags = SS_NO_INIT
var/global_max_tick_moves = 10
var/global_pixel_speed = 2
var/global_iterations_per_move = 16
+2 -2
View File
@@ -1,8 +1,8 @@
SUBSYSTEM_DEF(throwing)
name = "Throwing"
priority = FIRE_PRIORITY_THROWING
wait = 1
subsystem_flags = SS_NO_INIT | SS_KEEP_TIMING | SS_TICKER
wait = 0.25 // scale up to 40 fps
subsystem_flags = SS_NO_INIT
runlevels = RUNLEVEL_GAME | RUNLEVEL_POSTGAME
var/list/currentrun
+5
View File
@@ -29,6 +29,7 @@ SUBSYSTEM_DEF(timer)
name = "Timer"
wait = 1 // SS_TICKER subsystem, so wait is in ticks
init_order = INIT_ORDER_TIMER
runlevels = RUNLEVELS_ALL
priority = FIRE_PRIORITY_TIMER
subsystem_flags = SS_TICKER|SS_NO_INIT
@@ -664,6 +665,10 @@ SUBSYSTEM_DEF(timer)
stack_trace("addtimer called with a callback assigned to a qdeleted object. In the future such timers will not \
be supported and may refuse to run or run with a 0 wait")
if (wait == 0 && !flags)
SSdpc.queued_calls += callback
return
wait = max(CEILING(wait, world.tick_lag), world.tick_lag)
if(wait >= INFINITY)