Skip to content

Commit 0f67b86

Browse files
committed
Add ReentrantLock to LlmModule, matching Module.java pattern
Serializes access to non-thread-safe native state. Prevents accidental concurrent calls (e.g. double-tap, rotation during generation) from causing native crashes — second caller blocks until the first finishes. - generate()/prefill()/load()/resetContext() use lock() - close() uses tryLock() — fails fast, no ANR risk - stop() stays lock-free (native atomic flag for cross-thread interrupt) This commit was authored with the help of Claude.
1 parent 42776c9 commit 0f67b86

1 file changed

Lines changed: 191 additions & 110 deletions

File tree

  • extension/android/executorch_android/src/main/java/org/pytorch/executorch/extension/llm

0 commit comments

Comments
 (0)