mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-22 11:37:40 +01:00
Shuttles have air again. (#27884)
This commit is contained in:
@@ -85,6 +85,9 @@ SUBSYSTEM_DEF(air)
|
||||
/// Are we currently running in a MILLA-safe context, i.e. is is_synchronous *guaranteed* to be TRUE. Nothing outside of this file should change this.
|
||||
VAR_PRIVATE/in_milla_safe_code = FALSE
|
||||
|
||||
/// Are we in MILLA-safe code that can safely sleep?
|
||||
VAR_PRIVATE/safe_to_sleep = FALSE
|
||||
|
||||
/// A list of callbacks waiting for MILLA to finish its tick and enter synchronous mode.
|
||||
var/list/waiting_for_sync = list()
|
||||
var/list/sleepable_waiting_for_sync = list()
|
||||
@@ -724,16 +727,24 @@ SUBSYSTEM_DEF(air)
|
||||
waiting_for_sync += CB
|
||||
|
||||
/// Similar to addtimer, but triggers once MILLA enters synchronous mode. This version allows for sleeping if it's absolutely necessary.
|
||||
/datum/controller/subsystem/air/proc/sleepable_synchronize(datum/milla_safe/CB)
|
||||
/datum/controller/subsystem/air/proc/sleepable_synchronize(datum/milla_safe_must_sleep/CB)
|
||||
if(safe_to_sleep)
|
||||
var/was_safe = SSair.in_milla_safe_code
|
||||
SSair.in_milla_safe_code = TRUE
|
||||
// This is one of two intended places to call this otherwise-unsafe proc.
|
||||
CB.private_unsafe_invoke()
|
||||
SSair.in_milla_safe_code = was_safe
|
||||
return
|
||||
|
||||
sleepable_waiting_for_sync += CB
|
||||
|
||||
/datum/controller/subsystem/air/proc/is_in_milla_safe_code()
|
||||
return in_milla_safe_code
|
||||
|
||||
/datum/controller/subsystem/air/proc/on_milla_tick_finished()
|
||||
run_sleepless_callbacks()
|
||||
run_sleeping_callbacks()
|
||||
is_synchronous = TRUE
|
||||
run_sleepless_callbacks()
|
||||
|
||||
/datum/controller/subsystem/air/proc/run_sleepless_callbacks()
|
||||
// Just in case someone is naughty and decides to sleep, make sure that this method runs fully anyway.
|
||||
@@ -748,11 +759,13 @@ SUBSYSTEM_DEF(air)
|
||||
|
||||
/datum/controller/subsystem/air/proc/run_sleeping_callbacks()
|
||||
in_milla_safe_code = TRUE
|
||||
safe_to_sleep = TRUE
|
||||
for(var/datum/milla_safe_must_sleep/CB as anything in sleepable_waiting_for_sync)
|
||||
// This is one of two intended places to call this otherwise-unsafe proc.
|
||||
CB.private_unsafe_invoke()
|
||||
sleepable_waiting_for_sync.Cut()
|
||||
in_milla_safe_code = FALSE
|
||||
safe_to_sleep = FALSE
|
||||
|
||||
/proc/milla_tick_finished()
|
||||
// Any proc that wants MILLA to be synchronous should not sleep.
|
||||
|
||||
Reference in New Issue
Block a user