pub fn guard() -> GuardExpand description
Mark this thread for the length of the returned value, if the mode says so.
This is what a command loop wraps its dispatch in. It is a guard rather than a pair of calls because a panic in the middle of a batch would otherwise leave the thread marked for the rest of the process, and a thread that can never allocate again is a worse failure than the one being looked for.
A no-op under Mode::Off, down to not touching the thread local, so the
cost of having this in the loop when nobody asked for it is one relaxed load
per batch.