Function qadapt::exit_protected
source · pub fn exit_protected()
Expand description
Let QADAPT know that we are exiting a protected region. Will panic
if we attempt to exit_protected
more times than we enter_protected
.
Example:
use qadapt::enter_protected;
use qadapt::exit_protected;
fn main() {
// Force an allocation by using a Box
let x = Box::new(2);
enter_protected();
// We're now in a memory-protected region - allocations and drops
// here will trigger thread panic
let y = *x * 4;
exit_protected();
// It's now safe to allocate/drop again
let z = Box::new(y);
}