ScopedCounter
A thread-safe counter that tracks a depth value within nested scopes.
Parameters
maxDepth
maximum allowed depth. If exceeded, onOverflow is invoked
onOverflow
action to perform when the maximum depth is exceeded
Functions
Link copied to clipboard
Increments the counter, executes block, and decrements the counter when block completes. If the counter exceeds maxDepth, onOverflow is invoked before executing block.