Loading RustViz Engine...
Explicitly drop a lock guard early to prevent deadlocks in nested critical sections.
This problem is currently in blueprint template mode. Once the concept foundation is finalized, live in-browser WebAssembly compilation and test assertion runners will be enabled here.
use std::sync::Mutex;
pub fn update_and_notify(data: &Mutex<i32>) -> i32 {
let mut guard = data.lock().unwrap();
*guard += 1;
let val = *guard;
drop(guard); // Explicitly release lock before expensive notification
val
}