generated from WebAssembly/wasi-proposal-template
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Define types and functions in the proposal's template
- Loading branch information
Showing
2 changed files
with
44 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,34 @@ | ||
# Types | ||
|
||
## <a href="#api_type_one" name="api_type_one"></a> `api-type-one`: record | ||
## <a href="#thread_id" name="thread_id"></a> `thread-id`: `u32` | ||
|
||
Short description | ||
|
||
Explanation for developers using the API. | ||
Unique thread identifier. | ||
|
||
Size: 16, Alignment: 8 | ||
Size: 4, Alignment: 4 | ||
|
||
### Record Fields | ||
## <a href="#errno" name="errno"></a> `errno`: enum | ||
|
||
- <a href="api_type_one.property1" name="api_type_one.property1"></a> [`property1`](#api_type_one.property1): `u64` | ||
Error codes returned by the `thread-spawn` function. | ||
|
||
Size: 1, Alignment: 1 | ||
|
||
- <a href="api_type_one.property2" name="api_type_one.property2"></a> [`property2`](#api_type_one.property2): `string` | ||
### Enum Cases | ||
|
||
- <a href="errno.eagain" name="errno.eagain"></a> [`eagain`](#errno.eagain) | ||
|
||
TBD | ||
|
||
# Functions | ||
|
||
---- | ||
|
||
#### <a href="#api_function_one" name="api_function_one"></a> `api-function-one` | ||
#### <a href="#thread_spawn" name="thread_spawn"></a> `thread-spawn` | ||
|
||
Creates a new thread. | ||
##### Params | ||
|
||
Short description | ||
|
||
Explanation for developers using the API. | ||
- <a href="#thread_spawn.start_arg" name="thread_spawn.start_arg"></a> `start-arg`: handle<start-arg> | ||
##### Results | ||
|
||
- [`api-type-one`](#api_type_one) | ||
- result<[`thread-id`](#thread_id), [`errno`](#errno)> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,41 @@ | ||
# [Proposal Template] API | ||
# WASI threads API | ||
|
||
[This document contains the actual specification. It should be written in the WIT interface definition format. You can find more documentation on the WIT syntax (coming soon!).] | ||
WASI threads is an API for thread creation. | ||
|
||
[Note that all comments inside of WIT code blocks will be included in the developer facing documentation for language bindings generated using this WIT file. If there is additional information that needs to be communicated to implementers of the API, then these should be captured in text directly below the code block.] | ||
It's goal is to provide functions that allow implementation of a subset of `pthreads` API, but it doesn't aim to be 100% compatible with POSIX threads standard. | ||
|
||
[If you want to include examples of the API in use, these should be in the README and linked to from this file.] | ||
|
||
## api_type_one | ||
## thread-id | ||
|
||
```wit | ||
/// Short description | ||
/// | ||
/// Explanation for developers using the API. | ||
record api-type-one { | ||
property1: u64, | ||
property2: string, | ||
} | ||
/// Unique thread identifier. | ||
type thread-id = u32 | ||
``` | ||
|
||
More rigorous specification details for the implementer go here, if needed. | ||
## start-arg | ||
|
||
```wit | ||
/// A reference to data passed to the start function (`wasi_thread_start()`) called by the newly spawned thread. | ||
resource start-arg { | ||
} | ||
``` | ||
|
||
## api_function_one | ||
## errno | ||
|
||
```wit | ||
/// Short description | ||
/// | ||
/// Explanation for developers using the API. | ||
api-function-one: func() -> api-type-one | ||
/// Error codes returned by the `thread-spawn` function. | ||
enum errno { | ||
/// TBD | ||
eagain, | ||
} | ||
``` | ||
|
||
If needed, this would explain what a compliant implementation MUST do, such as never returning an earlier result from a later call. | ||
## thread_spawn | ||
|
||
```wit | ||
/// Creates a new thread. | ||
thread-spawn: func( | ||
/// A value being passed to a start function (`wasi_thread_start()`). | ||
start-arg: start-arg, | ||
) -> result<thread-id, errno> | ||
``` |