MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / begin

Function begin

codegraph-kernel/src/stack.rs:126–142  ·  view source on GitHub ↗

Arm the guard for one extraction on the calling thread: clear the latch and (re)compute the threshold. OS bounds are computed once per thread; the fallback budget is re-anchored at every call's entry stack pointer.

()

Source from the content-addressed store, hash-verified

124/// and (re)compute the threshold. OS bounds are computed once per thread;
125/// the fallback budget is re-anchored at every call's entry stack pointer.
126pub fn begin() {
127 OVERFLOWED.with(|o| o.set(false));
128 let cached = THRESHOLD.with(|t| t.get());
129 if cached != 0 && THRESHOLD_IS_OS.with(|f| f.get()) {
130 return;
131 }
132 match os_stack_low() {
133 Some(low) => {
134 THRESHOLD.with(|t| t.set(low.saturating_add(RED_ZONE)));
135 THRESHOLD_IS_OS.with(|f| f.set(true));
136 }
137 None => {
138 THRESHOLD.with(|t| t.set(current_sp().saturating_sub(FALLBACK_BUDGET).max(1)));
139 THRESHOLD_IS_OS.with(|f| f.set(false));
140 }
141 }
142}
143
144/// `true` once the walker has descended to within `RED_ZONE` of the stack
145/// limit. Latches `OVERFLOWED` so `run_guarded` can discard the result. A

Callers 2

exhaustedFunction · 0.85
run_guardedFunction · 0.85

Calls 5

os_stack_lowFunction · 0.85
current_spFunction · 0.85
withMethod · 0.80
getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected