Parent: #12, #1. Related: #17.
Goal
Give DisposableStack and AsyncDisposableStack resource records a no-GIL synchronization story for same-stack cross-thread calls.
Current state
The resource list is stored as an internal element-backed array (\x00ds_res) containing internal entry tuples [value, onDispose, kind]. The element-storage side can be moved behind Object.elements_lock / snapshots, but the stack also has observable mutable state:
\x00ds_done\x00ds_restransfer duringmove()- push/use/adopt/defer versus dispose/disposeAsync
- reverse disposal iteration while user callbacks run
A same-stack call from another thread can race a use/adopt/defer append with dispose/disposeAsync setting disposed, snapshotting/clearing resources, and invoking callbacks.
Acceptance criteria
- Decide/document whether DisposableStack objects are shared-realm callable from multiple JS threads or thread-affine.
- If shared, add a lock or equivalent synchronization around disposed-state publication, resource-list transfer, push, and disposal snapshot/clear.
- Do not hold the stack/resource lock across user disposal callbacks or awaited async disposal.
- Preserve reverse-disposal order and SuppressedError chaining.
- Add focused no-GIL coverage for concurrent same-stack push/dispose behavior.
- Update
docs/threads/bindings.mdwith the final ruling.