mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-18 05:32:58 +00:00
* More lua harddel fixes (#77556) ## About The Pull Request Fixes some more lua harddel problems with lingering refs on the gc_guard variable. This variable has been changed to a list instead and will get cleared every time the SSlua subsystem fires so that lua instantiated objects that are not tracked by the subsystem will essentially delete themselves on the next tick, aka whenever the lua script sleeps. Also removed the unnecessary and not completely functional lua_reference_cleanup proc which wasn't even being called reliably because the signal handler was the datum itself. ## Why It's Good For The Game Fixes more harddel bugs, increases consistency. Co-authored-by: Watermelon914 <3052169-Watermelon914@ users.noreply.gitlab.com> * More lua harddel fixes --------- Co-authored-by: Watermelon914 <37270891+Watermelon914@users.noreply.github.com> Co-authored-by: Watermelon914 <3052169-Watermelon914@ users.noreply.gitlab.com>
37 lines
1.1 KiB
Plaintext
37 lines
1.1 KiB
Plaintext
#define PROMISE_PENDING 0
|
|
#define PROMISE_RESOLVED 1
|
|
#define PROMISE_REJECTED 2
|
|
|
|
/**
|
|
* Auxtools hooks act as "set waitfor = 0" procs. This means that whenever
|
|
* a proc directly called from auxtools sleeps, the hook returns with whatever
|
|
* the called proc had as its return value at the moment it slept. This may not
|
|
* be desired behavior, so this datum exists to wrap these procs.
|
|
*
|
|
* Some procs that don't sleep could take longer than the execution limit would
|
|
* allow for. We can wrap these in a promise as well.
|
|
*/
|
|
/datum/auxtools_promise
|
|
var/datum/callback/callback
|
|
var/return_value
|
|
var/runtime_message
|
|
var/status = PROMISE_PENDING
|
|
|
|
/datum/auxtools_promise/New(...)
|
|
callback = CALLBACK(arglist(args))
|
|
perform()
|
|
|
|
/datum/auxtools_promise/proc/perform()
|
|
set waitfor = 0
|
|
sleep() //In case we have to call a super-expensive non-sleeping proc (like getFlatIcon)
|
|
try
|
|
return_value = callback.Invoke()
|
|
status = PROMISE_RESOLVED
|
|
catch(var/exception/e)
|
|
runtime_message = e.name
|
|
status = PROMISE_REJECTED
|
|
|
|
#undef PROMISE_PENDING
|
|
#undef PROMISE_RESOLVED
|
|
#undef PROMISE_REJECTED
|