Fragment debug_id u16 only exists in debug, prod will format mem address

This commit is contained in:
Mitchell Hentges 2016-05-26 18:36:19 +02:00
parent d890453f78
commit 43396c027d
2 changed files with 62 additions and 12 deletions

View file

@ -15,10 +15,12 @@ use std::borrow::ToOwned;
use std::cell::RefCell;
use std::fs::File;
use std::io::Write;
#[cfg(debug_assertions)]
use std::sync::atomic::{ATOMIC_USIZE_INIT, AtomicUsize, Ordering};
thread_local!(static STATE_KEY: RefCell<Option<State>> = RefCell::new(None));
#[cfg(debug_assertions)]
static DEBUG_ID_COUNTER: AtomicUsize = ATOMIC_USIZE_INIT;
pub struct Scope;
@ -96,6 +98,7 @@ impl Drop for Scope {
/// Generate a unique ID. This is used for items such as Fragment
/// which are often reallocated but represent essentially the
/// same data.
#[cfg(debug_assertions)]
pub fn generate_unique_debug_id() -> u16 {
DEBUG_ID_COUNTER.fetch_add(1, Ordering::SeqCst) as u16
}