mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-23 05:00:55 +01:00
[MIRROR] Optimizes INVOKE_ASYNC by making it a macro and avoiding a proc call [MDB IGNORE] (#19668)
* Optimizes INVOKE_ASYNC by making it a macro and avoiding a proc call (#73264) ## About The Pull Request This is quite literally the same behavior but faster, and also catches improper arguments better than the old macro/proc approach. Credit to Lohikar for writing the macro. Port of https://github.com/DaedalusDock/daedalusdock/pull/196 Also, `world.ImmediateInvokeAsync()` never set a return value, so expecting one was never valid behavior. At MSO's request, the documentation of `spawn(-1)`: As per the reference, calling `spawn()` with a negative value will execute the spawned code until a blocking action (such as `sleep()`) is encountered. Then, it will step outside of the spawned code, and continue the proc. This is the same behavior as calling a `waitfor = FALSE` proc. Specifically, under the hood, `spawn(-1)` creates a copy of the callstack like `sleep()`, incase the spawned code is blocked and needs to be rescheduled. As an added bonus, `spawn(-1)` silences SHOULD_NOT_SLEEP errors, whereas `waitfor = FALSE` does not. ## Why It's Good For The Game ITS FREE FUCKING CPU TIME --------- Co-authored-by: Mothblocks <35135081+Mothblocks@ users.noreply.github.com> Co-authored-by: Kyle Spier-Swenson <kyleshome@ gmail.com> * Optimizes INVOKE_ASYNC by making it a macro and avoiding a proc call --------- Co-authored-by: Kapu1178 <75460809+Kapu1178@users.noreply.github.com> Co-authored-by: Mothblocks <35135081+Mothblocks@ users.noreply.github.com> Co-authored-by: Kyle Spier-Swenson <kyleshome@ gmail.com>
This commit is contained in:
co-authored by
Mothblocks
Kyle Spier-Swenson
Kapu1178
parent
f4327644a2
commit
c41ff0aaa6
@@ -384,7 +384,9 @@
|
||||
outer_plating_amount=1
|
||||
|
||||
/datum/component/construction/mecha/gygax/action(datum/source, atom/used_atom, mob/user)
|
||||
return INVOKE_ASYNC(src, PROC_REF(check_step), used_atom,user)
|
||||
ASYNC //This proc will never actually sleep, it calls do_after with a time of 0.
|
||||
. = check_step(used_atom, user)
|
||||
return .
|
||||
|
||||
//CLARKE
|
||||
/datum/component/construction/unordered/mecha_chassis/clarke
|
||||
|
||||
Reference in New Issue
Block a user