Skip to content

Commit

Permalink
UNTIL_OR_TIMEOUT macro (#6438)
Browse files Browse the repository at this point in the history
# About the pull request
UNTIL() but you can add a timeout. This shouldn't be used except with
rustg HTTP requests. Complete bandaid, but it's what needs to be done

---------

Co-authored-by: John Doe <[email protected]>
  • Loading branch information
Zonespace27 and johndoe2013 committed Jun 12, 2024
1 parent 8a350f4 commit 37fcb6e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions code/__HELPERS/unsorted.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1501,6 +1501,19 @@ GLOBAL_DATUM_INIT(dview_mob, /mob/dview, new)

#define UNTIL(X) while(!(X)) stoplag()

/// Macro for cases where an UNTIL() may go on forever (such as for an http request)
#define UNTIL_OR_TIMEOUT(X, __time) \
do {\
__time = max(__time, 0);\
var/__start_time = world.time;\
while(!(X)) {;\
stoplag();\
if(__start_time + __time <= world.time) {;\
CRASH("UNTIL_OR_TIMEOUT hit timeout limit of [__time]");\
};\
};\
} while(FALSE)

//Repopulates sortedAreas list
/proc/repopulate_sorted_areas()
GLOB.sorted_areas = list()
Expand Down

0 comments on commit 37fcb6e

Please sign in to comment.