Per-KB counts of named expensive calls, each name with the most calls one KB may take.
While count! counts, counted adds one to the KB's count for its name, unless a call
under that name running on this thread has counted. allow raises one KB's limit under
a name and records why, and entries lists the counts with any allowance. A KB is keyed
by object identity and held weakly. With counting off, counted costs one atom read.
To guard a call, declare its name once as (def name (call-cap/capped ::name n)) and
wrap each call site as (call-cap/counted name kb #(...)).
Per-KB counts of named expensive calls, each name with the most calls one KB may take. While `count!` counts, `counted` adds one to the KB's count for its name, unless a call under that name running on this thread has counted. `allow` raises one KB's limit under a name and records why, and `entries` lists the counts with any allowance. A KB is keyed by object identity and held weakly. With counting off, `counted` costs one atom read. To guard a call, declare its name once as `(def name (call-cap/capped ::name n))` and wrap each call site as `(call-cap/counted name kb #(...))`.
(allow name kb n reason)While counting, let kb take up to n calls under name in place of name's cap,
reason saying why it takes them.
While counting, let `kb` take up to `n` calls under `name` in place of `name`'s cap, `reason` saying why it takes them.
(capped name cap)Declare name with cap, the most counted calls under name one KB may take, and
return name.
Declare `name` with `cap`, the most `counted` calls under `name` one KB may take, and return `name`.
(count!)(count! tag)Count from zero, tag naming a KB's caller at its first counted call under a name, or
stop counting with no argument.
Count from zero, `tag` naming a KB's caller at its first counted call under a name, or stop counting with no argument.
(counted name kb f)Run (f) as one call under name on kb: while counting, add one to kb's count for
name, unless a call under name running on this thread has counted.
Run `(f)` as one call under `name` on `kb`: while counting, add one to `kb`'s count for `name`, unless a call under `name` running on this thread has counted.
(entries)Each count as {:name n :kb k :tag t :count c :cap m}: k names the KB by its identity
hash, t is the count! tag's value at its first call or allowance, and m is n's
cap. An entry given an allow also holds :allow and :reason.
Each count as `{:name n :kb k :tag t :count c :cap m}`: `k` names the KB by its identity
hash, `t` is the `count!` tag's value at its first call or allowance, and `m` is `n`'s
cap. An entry given an `allow` also holds `:allow` and `:reason`.(scope name f)Run (f) as at most one call under name: the first counted call under name that
f runs counts, and the rest count nothing.
Run `(f)` as at most one call under `name`: the first `counted` call under `name` that `f` runs counts, and the rest count nothing.
(uncounted name f)Run (f) with no count under name, as part of a call counted where it began.
Run `(f)` with no count under `name`, as part of a call counted where it began.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |