Skip to content

Commit

Permalink
Support non-unique TIMER_CLIENT_TIME timers in SSdpc
Browse files Browse the repository at this point in the history
  • Loading branch information
out-of-phaze committed Aug 20, 2024
1 parent e184cee commit 953b5b0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion code/__defines/MC.dm
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ if(Datum.is_processing) {\
// TIMER_OVERRIDE is impossible to support because we don't track that for DPC queued calls, and adding a third list for that would be a lot of overhead for no real benefit
// TIMER_STOPPABLE can't work because it uses timer IDs instead of hashes, and DPC queued calls don't have IDs.
// TIMER_LOOP doesn't work because it needs to be a timer that can re-insert in the list, and a zero-wait looping timer should really be a ticker subsystem instead.
// Update this define if any of those change.
// Update these defines if any of those change.
/// These are the flags forbidden when putting zero-wait timers on SSdpc instead of SStimer.
#define DPC_FORBID_FLAGS TIMER_UNIQUE | TIMER_OVERRIDE | TIMER_STOPPABLE | TIMER_LOOP
/// These are the flags forbidden when putting zero-wait TIMER_UNIQUE timers on SSdpc instead of SStimer.
#define UDPC_FORBID_FLAGS TIMER_OVERRIDE | TIMER_STOPPABLE | TIMER_LOOP

Expand Down
4 changes: 2 additions & 2 deletions code/controllers/subsystems/DPC.dm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
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.
timers with certain flags (check MC.dm). This doesn't need to be explicitly used, eligible timers are automatically converted.
*/

SUBSYSTEM_DEF(dpc)
Expand All @@ -17,7 +17,7 @@ SUBSYSTEM_DEF(dpc)
var/unique_avg = 0

/datum/controller/subsystem/dpc/stat_entry()
return ..() + " Q: [queued_calls.len], AQ: ~[round(avg)], UQ: [unique_queued_calls.len], AQ: ~[round(unique_avg)]"
return ..() + " Q: [queued_calls.len], AQ: ~[round(avg)], UQ: [unique_queued_calls.len], UAQ: ~[round(unique_avg)]"

/datum/controller/subsystem/dpc/fire(resumed = FALSE)
var/list/qc = queued_calls
Expand Down
2 changes: 1 addition & 1 deletion code/controllers/subsystems/timer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ SUBSYSTEM_DEF(timer)
PRINT_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)
if (wait == 0 && !(flags & DPC_FORBID_FLAGS))
SSdpc.queued_calls += callback
return

Expand Down

0 comments on commit 953b5b0

Please sign in to comment.