1
0
mirror of https://github.com/bspeice/qadapt synced 2024-11-25 07:18:17 -05:00

Minor note about protection level during release

This commit is contained in:
Bradlee Speice 2019-01-20 13:29:38 -05:00
parent 8838070a1b
commit 87beb53ccd

View File

@ -263,7 +263,9 @@ macro_rules! assert_no_alloc {
static IS_ACTIVE: RwLock<bool> = RwLock::new(false); static IS_ACTIVE: RwLock<bool> = RwLock::new(false);
static INTERNAL_ALLOCATION: RwLock<usize> = RwLock::new(usize::max_value()); static INTERNAL_ALLOCATION: RwLock<usize> = RwLock::new(usize::max_value());
/// Get the current "protection level" in QADAPT: calls to enter_protected() - exit_protected() /// Get the current "protection level" in QADAPT: calls to `enter_protected() - exit_protected()`.
///
/// **Note**: For release builds, `protection_level()` will always return 0.
/// ///
/// **Example**: /// **Example**:
/// ///
@ -290,11 +292,7 @@ static INTERNAL_ALLOCATION: RwLock<usize> = RwLock::new(usize::max_value());
/// // It's now safe to allocate/drop /// // It's now safe to allocate/drop
/// } /// }
pub fn protection_level() -> usize { pub fn protection_level() -> usize {
if cfg!(debug_assertions) { PROTECTION_LEVEL.try_with(|v| *v.read()).unwrap_or(0)
PROTECTION_LEVEL.try_with(|v| *v.read()).unwrap_or(0)
} else {
0
}
} }
/// Determine whether qadapt is running as the current global allocator. Useful for /// Determine whether qadapt is running as the current global allocator. Useful for