> ## Documentation Index
> Fetch the complete documentation index at: https://developer.sanas.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Threading & Lifetime Rules

> Thread-safety, callback constraints, and object lifetime for the SDK

* All SDK methods are thread-safe. You may call them from multiple threads simultaneously.
* Callbacks (`onState`, `onTranscript`) run on background threads managed by the SDK. Keep them fast, non-blocking, and synchronised — use `std::atomic` or `std::mutex` for any shared state they touch.
* `ProcessSamples` blocks for one frame while the SDK reads processed audio from its internal buffer. Call it from your audio thread, not from inside a callback.
* Keep the `shared_ptr<IAudioProcessor>` alive for as long as you use the processor. Call `DestroyAudioProcessor` when done, then `Shutdown` last.

<Warning>Never call `DestroyAudioProcessor` or `Shutdown` from inside an `onState` or `onTranscript` callback. Doing so causes a deadlock.</Warning>
