Skip to main content

claim_auto_turn

Function claim_auto_turn 

Source
pub fn claim_auto_turn(counter: &mut u32) -> bool
Expand description

Centralised auto-turn claim gate.

Semantics (single source of truth):

  • cap == 0 → always allowed (unlimited): increment counter, return true.
  • counter < cap → allowed: increment counter and return true.
  • counter >= cap → denied: leave counter unchanged, return false.
  • User input resets counter to 0 (caller responsibility — not this function).

claim_auto_turn uses the default AUTO_TURN_CAP; production callers should use claim_auto_turn_with_cap with the configured events.auto_turn_cap.

All paths that may fire an auto-triggered model turn (TUI event arm, TUI stream arm, chat EventWake, chat AutoTriggerEvents, server idle wake, server AutoTriggerEvents) must call this function and bail when it returns false instead of duplicating the fetch_add / >= cap pattern inline.

§Arguments

  • counter — mutable reference to the caller’s u32 counter.

§Returns

true if a turn is allowed (counter was incremented), false if parked.