-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use WIT's result<> type for thread-spawn
's return values
#29
Comments
|
CC-ing @lukewagner who may have an opinion about this issue. If wasi-threads is defined as a core module, should it use WIT's |
When WIT is extended to describe core modules, I would expect, as a starting point, it would start with just core value types. While you could imagine supporting a subset of component-level types that had a clear mapping to scalar core value types, it would pretty quickly stop working as soon as linear memory got involved and I expect what we'd want would look a lot more like the explicit "pointer" approach of witx (from which you could generate C header-file-style bindings, but not higher-level language bindings automatically). Without thinking through the design of this, it's hard to know if we'd want to attempt to share types like |
Because
thread-spawn
can fail, we use return value to communicate error code. We also use return value to communicate success and pass thread id to the user. This usecase nicely fits into variant type, and more specifically -result<>
. It also feels like an idiomatic way of handling this kind of usecase in WIT.I propose we update the type of
thread-spawn
to be:start-arg
where
thread-id
is a non-negative integer (type start-arg = u32
) anderrno
is an enum representing all potential errors returned bythread-spawn
.Please note that the consequence of this change is updated C interface:
where the second parameter is a pointer to a memory dedicated for the return value.
I'm seeking for feedback/suggestions; once we have a high-level agreement, the next steps are:
[ ] define (initial) set of error codes
[ ] update proposal and WIT definition (#28)
[ ] update toolchains (wasi-libc, ...?)
[ ] update runtimes that already implemented the proposal or have the work in-progress (wasmtime, WAMR, ...?)
See also: #26
The text was updated successfully, but these errors were encountered: