rune/runtime/budget/
std.rs

1
2
3
4
5
6
7
8
9
10
11
use core::cell::Cell;

std::thread_local!(static BUDGET: Cell<usize> = const { Cell::new(usize::MAX) });

pub(super) fn rune_budget_get() -> usize {
    BUDGET.with(|tls| tls.get())
}

pub(super) fn rune_budget_replace(value: usize) -> usize {
    BUDGET.with(|tls| tls.replace(value))
}