pub struct OncePerRun(/* private fields */);Expand description
A latch for a warning raised from an innermost analysis loop, where the same message can be produced millions of times — once per bad base, once per unreadable read.
Declared as a static beside the code that raises the warning, so asking
whether to speak is one relaxed atomic: no formatting, no allocation and no
lock on the overwhelmingly common repeat. That matters because these sit in
the hot loop — building the message unconditionally and then discarding it
cost ~26% of the analysis on a file whose every base tripped the warning.
The latch is per run, not per process: it resets when the next
ProgressPlan is created, so an embedder driving the library twice hears
the warning both times. Within a run it fires once however many files are
being analysed in parallel, which is the point — the warning is about the
data, and one copy of it is the useful amount.
Implementations§
Source§impl OncePerRun
impl OncePerRun
pub const fn new() -> Self
Sourcepub fn should_say(&self) -> bool
pub fn should_say(&self) -> bool
True for exactly one caller per run. Racing threads all swap in the current run, and only the one that displaced an older value speaks. The plain load first keeps repeats off the cache line’s write path.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for OncePerRun
impl RefUnwindSafe for OncePerRun
impl Send for OncePerRun
impl Sync for OncePerRun
impl Unpin for OncePerRun
impl UnsafeUnpin for OncePerRun
impl UnwindSafe for OncePerRun
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.