pub struct FreezeState { /* private fields */ }Expand description
State for managing process freezing.
Uses an epoch counter to prevent race conditions where a freeze is scheduled but work arrives before it executes. The epoch is incremented on unfreeze, and freeze operations check the epoch matches before proceeding.
Supports freezing multiple PIDs (runtime + extensions) to accurately simulate
Lambda’s behaviour where the entire execution environment is frozen. PIDs can
be registered dynamically after creation using register_pid().
Implementations§
Source§impl FreezeState
impl FreezeState
Sourcepub fn new(mode: FreezeMode, pid: Option<u32>) -> Self
pub fn new(mode: FreezeMode, pid: Option<u32>) -> Self
Creates a new freeze state with a single PID (for backwards compatibility).
Sourcepub fn with_pids(mode: FreezeMode, pids: Vec<u32>) -> Self
pub fn with_pids(mode: FreezeMode, pids: Vec<u32>) -> Self
Creates a new freeze state with multiple PIDs.
Use this to freeze the runtime and all extension processes together, which accurately simulates Lambda’s freeze behaviour.
Sourcepub fn mode(&self) -> FreezeMode
pub fn mode(&self) -> FreezeMode
Returns the current freeze mode.
Sourcepub fn pid(&self) -> Option<i32>
pub fn pid(&self) -> Option<i32>
Returns the first configured PID, if any (for backwards compatibility).
Sourcepub fn register_pid(&self, pid: u32)
pub fn register_pid(&self, pid: u32)
Registers a PID to be frozen/unfrozen with the execution environment.
Call this after spawning runtime or extension processes to include them in freeze/thaw operations.
Sourcepub fn current_epoch(&self) -> u64
pub fn current_epoch(&self) -> u64
Returns the current freeze epoch.
Sourcepub async fn wait_for_state_change(&self)
pub async fn wait_for_state_change(&self)
Waits for the freeze state to change.