Skip to content

Remove OS Thread from Atomics Wait Async#989

Open
komyg wants to merge 9 commits into
trynova:mainfrom
komyg:fix/remove-thread-from-wait-async
Open

Remove OS Thread from Atomics Wait Async#989
komyg wants to merge 9 commits into
trynova:mainfrom
komyg:fix/remove-thread-from-wait-async

Conversation

@komyg

@komyg komyg commented May 7, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@komyg komyg changed the title Fix/remove thread from wait async Remove OS Thread from Atomics Wait Async May 7, 2026

@aapoalas aapoalas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good to me, but I had a few nitpicks regarding the inline comments that I'd like to fix before merging :)


// SAFETY: buffer is a cloned SharedDataBlock; non-dangling.
let waiters = unsafe { self.0.data_block.get_or_init_waiters() };
// a. Perform EnterCriticalSection(WL).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick (but blocking): I'd like to see here a reference to where these steps are coming from. Possibly also a link to the relevant spec method.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is the implementation of the Job Abstract Closure for WaitAsyncTimeoutJob, when there is no timeout.

AFAIK the spec only defines the case with a timeout, but we have separated them, so I don't think that there is a specifc spec reference that I can add.

Therefore, I removed the comments referencing the steps.

));
}
}
// c. Perform LeaveCriticalSection(WL).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick (blocking): Step b is missing. I assume that'd be removing the waiter from the list, but I'd want to see it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See here: #989 (comment)

Comment thread nova_vm/src/ecmascript/builtins/structured_data/atomics_object.rs Outdated
}

// SAFETY: buffer is a cloned SharedDataBlock; non-dangling.
let waiters = unsafe { self.0.data_block.get_or_init_waiters() };

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: This seems like it could be a helper method.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is an unsafe operation, IMO it would be better to have this inline, so that this fact is not hidden from the user by an abstraction.

@komyg komyg force-pushed the fix/remove-thread-from-wait-async branch from ffa98bd to 3f07edc Compare June 8, 2026 20:03
@komyg komyg requested a review from aapoalas June 10, 2026 00:00
@komyg

komyg commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

Hey @aapoalas, I've addressed your comments. Can you review again, please?

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