macro_rules! singleton_token {
($(#[$meta: meta])* $vis: vis $id: ident) => { ... };
($($(#[$meta: meta])* $vis: vis $id: ident),*) => { ... };
}Expand description
Produces tokens whose only identifier is their type, but is built such that only one instance of it can exist at any given time.
Looping on TokenTrait::new with a singleton token to access a TokenCell is equivalent to using a spin-lock.
Note that you’re almost always better off placing an [unsafe_token] inside a Mutex instead if you expect contention on the token.