[−][src]Function qadapt::exit_protected
pub fn exit_protected()
Deprecated since 1.0.3:
Please use the alloc_counter
crate instead.
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; use qadapt::QADAPT; #[global_allocator] static Q: QADAPT = QADAPT; 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); }