Archived
util: a log_once for the warnings that speak once per process
Three sites -- the kvstream clamp (L-02), the batch overlap guard and the bidi-plane belt -- each open-coded the same four lines: a function- local static atomic<bool>, a bool expected, and a compare_exchange to decide which of the many steps gets to print. The pattern is the point, not the flag name (said, said2), so it moved to rad_internal.h as log_once(flag): true on the first call, false after. No behaviour change -- same first-of-many warnings, same compare-exchange thread-safety, exactly one winner per flag -- only the idiom is now named instead of re-typed where a fourth once-warning is ever needed.
This commit is contained in:
1 parent
b9ecbde0d6
commit
c3a4775f54
3 files changed
+12
-6
No files matched your search
@@ -1082,8 +1082,7 @@ const RadBatch* BatchBuilder::build(const StepPlan& plan, const IKVManager& kv,
|
||||
if (a >= b || pm.items[(size_t)run.item].item->kind == mm::Kind::Audio) continue;
|
||||
if (a < prev_b) {
|
||||
static std::atomic<bool> said{false};
|
||||
bool expected = false;
|
||||
if (said.compare_exchange_strong(expected, true))
|
||||
if (log_once(said))
|
||||
RAD_WARN("step batch: a rope layout overlaps at token %lld; that run is "
|
||||
"not staged bidirectionally (first of possibly many)",
|
||||
(long long)a);
|
||||
@@ -1094,8 +1093,7 @@ const RadBatch* BatchBuilder::build(const StepPlan& plan, const IKVManager& kv,
|
||||
/* Belt: the disjoint check makes this unreachable; the slice says so
|
||||
* rather than letting an overrun reach the card. */
|
||||
static std::atomic<bool> said2{false};
|
||||
bool expected = false;
|
||||
if (said2.compare_exchange_strong(expected, true))
|
||||
if (log_once(said2))
|
||||
RAD_WARN("step batch: bidi runs overflowed the %lld-token plane "
|
||||
"(first of possibly many)", (long long)T);
|
||||
break;
|
||||
|
||||
Reference in new issue
Block a user