1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//! This crate implements global, thread-safe counters.
//!
//! Concerning performance, the general ranking is, from fastest to slowest:
//!
//! * [Flushing primitive counters](primitive/fast/index.html)
//! * [Approximate primitive counters](primitive/fast/index.html)
//! * [Exact primitive atomic counters](primitive/exact/index.html)
//! * [Generic counter](generic/struct.Counter.html)
//!
//! Don't forget to make your own benchmarks, as those are very specific to the computing system in general and, in this case, to the OS in specific.

extern crate lazy_static;

// We need to pub use lazy_static, as global_(default_)counter! is expanded to a lazy_static! call.
// Absolute paths wont help here.
// TODO: Think of a way to only pub reexport the lazy_static! macro.
#[doc(hidden)]
pub use lazy_static::*;

/// This module contains a global, generic counter and the accompanying `Inc` trait.
pub mod generic;

/// This module contains global counters for primitive integer types.
pub mod primitive;

// Hack for macro export.
// In foreign crates, `global_counter::generic::Counter` will be the name of our counter,
// but in this crate (for testing), we need to artificially introduce this path.
// TODO: Think of a better way to do this.
#[doc(hidden)]
pub mod global_counter {
    pub mod generic {
        pub type Counter<T> = crate::generic::Counter<T>;
    }
}