Skip to content

Atomics waiters on sync.Mutex and per-waiter futex words - #433

Merged
julia-script merged 1 commit into
mainfrom
claude/project-thread-1pyw9h
Nov 5, 2026
Merged

julia-script merged 1 commit into
mainfrom
claude/project-thread-1pyw9h

Conversation

@julia-script

Copy link
Copy Markdown
Owner

js_atomics_native no longer declares pthread mutex, condition or clock FFI.

  • The shared waiter queue's lock is now a stdlib sync.Mutex<()>, held through guards.
  • Each waiter sleeps on its own woken word with Atomic.wait and a relative timeout, so no per-waiter condition is needed and there are still no allocations under the lock.
  • Notify and cancel set the word and wake the waiter while holding the lock, so the waiter's stack frame stays live through the wake. This is the same guarantee the stack condition had.
  • Gone with the FFI: the opaque 64-byte NativeMutex/NativeCondition ABI envelopes, the target restriction, clock_gettime deadline math and the test's nanosleep.
  • Spurious wakeups still return "ok", as before.

unsafe count in the file: 98 → 77.

Local gate: build clean, 512/512 tests including both waiter regression tests, all checks passed, and segb/collb/lpb/relb were SAME.


Generated by Claude Code

The waiter queue lock is a stdlib Mutex and each waiter sleeps on its own
word with Atomic.wait, so the pthread mutex/condition FFI, the 64-byte ABI
envelopes and the per-target clock_gettime deadline code are gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011ZVEnRWZMhoT2rtkwELgh3
@julia-script
julia-script merged commit d860c20 into main Nov 5, 2026
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.

2 participants