Skip to content

Add per-context interrupt budget#1526

Open
dannote wants to merge 1 commit into
quickjs-ng:masterfrom
dannote:context-interrupt-budget
Open

Add per-context interrupt budget#1526
dannote wants to merge 1 commit into
quickjs-ng:masterfrom
dannote:context-interrupt-budget

Conversation

@dannote
Copy link
Copy Markdown

@dannote dannote commented Jun 6, 2026

Add a context-local interrupt counter and optional limit.

The counter increments when the interpreter reaches the existing interrupt polling path. If a context limit is set and the counter reaches it, that context throws interrupted before consulting the runtime-level interrupt handler. A limit of 0 keeps the feature disabled.

This is useful for embedders that host multiple JSContext instances inside one JSRuntime and need each context to have an independent execution budget. In QuickBEAM, a pool worker owns one JSRuntime and creates many contexts with JS_NewContext(rt). A runtime-level interrupt handler remains useful as a global guard, but it cannot express a per-context budget for that pooled model.

Tested:

cmake --build build --target api-test -j2
./build/api-test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant