Files
Bubberstation/code/__HELPERS/varset_callback.dm
SkyratBot 6a9036149c [MIRROR] Significantly speed up create & destroy by reducing the amount of time to wait for GC [MDB IGNORE] (#20459)
* Significantly speed up create & destroy by reducing the amount of time to wait for GC (#74604)

The check queue is 5 minutes long because that's the longest a client
can hold onto a reference. Without clients, we can drastically decrease
the time we have to wait. This lowers the time down to 10 seconds
(though everything right now deletes in 5).

This will represent a 5 minute decrease in CI across the board, freeing
up runners.

Makes a few changes to stuff that was being held for more than 10
seconds.
- `VARSET_CALLBACK` now works through weakrefs, to allow for pAIs to
have their holochassis init timers.
- Nar'Sie cleans herself up in GLOB.cult_narsie if she's deleted.
- "Spooky portals" no longer hold onto a reference for 2 minutes.
- `poll_candidates` short circuits to an empty list if there are no
candidates, to avoid several 30 second+ long timers

Originally this was going to be a more clever hack from @ MrStonedOne
about short circuiting if everything deletes before the wait, but we
realized that basically nothing actually holds onto references for that
long without clients, and that nothing really should anyway

* Significantly speed up create & destroy by reducing the amount of time to wait for GC

---------

Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
2023-04-09 19:36:44 -07:00

25 lines
1.1 KiB
Plaintext

#define VARSET_LIST_CALLBACK(target, var_name, var_value) CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(___callbackvarset), ##target, ##var_name, ##var_value)
//dupe code because dm can't handle 3 level deep macros
#define VARSET_CALLBACK(datum, var, var_value) CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(___callbackvarset), ##datum, NAMEOF(##datum, ##var), ##var_value)
/// Same as VARSET_CALLBACK, but uses a weakref to the datum.
/// Use this if the timer is exceptionally long.
#define VARSET_WEAK_CALLBACK(datum, var, var_value) CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(___callbackvarset), WEAKREF(##datum), NAMEOF(##datum, ##var), ##var_value)
/proc/___callbackvarset(list_or_datum, var_name, var_value)
if(length(list_or_datum))
list_or_datum[var_name] = var_value
return
var/datum/datum = list_or_datum
if (isweakref(datum))
var/datum/weakref/datum_weakref = datum
datum = datum_weakref.resolve()
if (isnull(datum))
return
if(IsAdminAdvancedProcCall())
datum.vv_edit_var(var_name, var_value) //same result generally, unless badmemes
else
datum.vars[var_name] = var_value