Function lock

Source
pub fn lock() -> ConfigLock
Expand description

Acquire the global configuration lock.

This lock serializes all mutations of the global configuration, ensuring they cannot clobber each other. It returns a ConfigLock guard, which must be held for the duration of any mutation (e.g. inserting or overriding values).

Most commonly used in tests, where it provides exclusive access to push a Source::TestOverride layer via ConfigLock::override_key. The override layer is automatically removed when the guard drops, restoring the original state.

§Example

let lock = hyperactor::config::global::lock();
let _guard = lock.override_key(CONFIG_KEY, "test_value");
// Code under test sees the overridden config.
// On drop, the key is restored.