macro_rules! static_unique_domain {
    ($v:vis static $domain:ident: Domain<$family:ident>) => { ... };
}
Expand description

Generate a static Domain with an entirely unique domain family.

Usage: static_unique_domain!(static DOMAIN: Domain<Family>);

This macro is useful when you want to store a domain in a static variable, and makes it possible to name the Domain. The generated family implements Singleton, which enables the use of AtomicPtr::safe_load. This means it’s impossible to construct an instance of Family outside of this macro, despite the ability to name the Family Type.

This is useful since it allows you to store the HazardPointers aquired from this domain, since the Family type can now be named.

static_unique_domain!(static LOCAL: Domain<Local>);

struct ContainsHazardPointers<'domain> {
    haz_ptr: HazardPointer<'domain, Local>,
    val: AtomicPtr<DataStructure, Local>,
}

impl ContainsHazardPointers<'_> {
    fn read(&mut self) -> Option<&DataStructure> {
        self.val.safe_load(&mut self.haz_ptr)
    }
}

Notes

This macro cannot be used in a function scope or impl block. This macro (at least currently) requires the ability to define a module, and therefore must be placed in module scope. This may be relaxed in the future, but hopefully shouldn’t be exteneded.

This also restricts the ability to define a struct or module with the same name as the static variable, or the family.