2020-08-13 19:57:59 +03:00
|
|
|
#[cfg(not(test))]
|
|
|
|
use std::sync::atomic::AtomicUsize;
|
|
|
|
#[cfg(not(test))]
|
|
|
|
static PARA_ID: AtomicUsize = AtomicUsize::new(1);
|
|
|
|
|
|
|
|
#[cfg(not(test))]
|
|
|
|
pub fn generate_para_id() -> String {
|
|
|
|
use std::sync::atomic::Ordering;
|
|
|
|
|
|
|
|
let id = PARA_ID.load(Ordering::Relaxed);
|
|
|
|
PARA_ID.store(id.wrapping_add(1), Ordering::Relaxed);
|
|
|
|
format!("{:08x}", id)
|
|
|
|
}
|
|
|
|
|
2020-12-21 13:52:15 +02:00
|
|
|
#[cfg(not(test))]
|
|
|
|
pub fn reset_para_id() {
|
|
|
|
use std::sync::atomic::Ordering;
|
|
|
|
|
|
|
|
PARA_ID.load(Ordering::Relaxed);
|
|
|
|
PARA_ID.store(1, Ordering::Relaxed);
|
|
|
|
}
|
|
|
|
|
2020-08-13 19:57:59 +03:00
|
|
|
#[cfg(test)]
|
|
|
|
pub fn generate_para_id() -> String {
|
|
|
|
"12345678".to_owned()
|
|
|
|
}
|
2020-12-21 13:52:15 +02:00
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
pub fn reset_para_id() {
|
|
|
|
// NOP
|
|
|
|
}
|