Skip to content

poll: Add pollAsync API to the stream backend#26196

Draft
ktock wants to merge 1 commit intoemscripten-core:mainfrom
ktock:pollasync
Draft

poll: Add pollAsync API to the stream backend#26196
ktock wants to merge 1 commit intoemscripten-core:mainfrom
ktock:pollasync

Conversation

@ktock
Copy link
Contributor

@ktock ktock commented Feb 1, 2026

Discussed in #26192

This PR only contains the refactoring of the APIs following the suggestion in #26192. I think we need additional patches if we want to fully restore the legacy behavior (i.e. ignoring the timeout argument) for the sockfs.

This commit refactors the stream backend's poll API and explicitly splits it into synchronous and asynchronous APIs. The poll API synchronously checks the events. The backend can also implement the pollAsync API which can wait for the event asynchronously and notify the caller using the callback when the event occurs.

This commit refactors the stream backend's poll API and explicitly splits it
into synchronous and asynchronous APIs. The poll API synchronously checks
the events. The backend can also implement the pollAsync API which can wait
for the event asynchronously and notify the caller using the callback when
the event occurs.

Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
Copy link
Collaborator

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

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

looks like a good direction.

}
}

#if PTHREADS
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm.. I do you know why this isn't #if PTHREADS || ASYNCIFY like it is in libsyscall.sj.. I'm suprised that the tests still pass despite this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah.. that was a real bug: #26206

pollAsync(stream, notifyCallback) {
var res = this.poll(stream, 0);
if (res != 0) return res;
#if PTHREADS
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the whole of pollAsync should probably be wrapped in #if PTHREADS || ASYNCIFY

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