Skip to content

Commit e151ef6

Browse files
committed
Define types and functions in the proposal's template
1 parent 9d4364b commit e151ef6

File tree

2 files changed

+44
-32
lines changed

2 files changed

+44
-32
lines changed

proposal-template.abi.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,34 @@
11
# Types
22

3-
## <a href="#api_type_one" name="api_type_one"></a> `api-type-one`: record
3+
## <a href="#thread_id" name="thread_id"></a> `thread-id`: `u32`
44

5-
Short description
6-
7-
Explanation for developers using the API.
5+
Unique thread identifier.
86

9-
Size: 16, Alignment: 8
7+
Size: 4, Alignment: 4
108

11-
### Record Fields
9+
## <a href="#errno" name="errno"></a> `errno`: enum
1210

13-
- <a href="api_type_one.property1" name="api_type_one.property1"></a> [`property1`](#api_type_one.property1): `u64`
11+
Error codes returned by the `thread-spawn` function.
1412

13+
Size: 1, Alignment: 1
1514

16-
- <a href="api_type_one.property2" name="api_type_one.property2"></a> [`property2`](#api_type_one.property2): `string`
15+
### Enum Cases
1716

17+
- <a href="errno.eagain" name="errno.eagain"></a> [`eagain`](#errno.eagain)
18+
19+
TBD
1820

1921
# Functions
2022

2123
----
2224

23-
#### <a href="#api_function_one" name="api_function_one"></a> `api-function-one`
25+
#### <a href="#thread_spawn" name="thread_spawn"></a> `thread-spawn`
26+
27+
Creates a new thread.
28+
##### Params
2429

25-
Short description
26-
27-
Explanation for developers using the API.
30+
- <a href="#thread_spawn.start_arg" name="thread_spawn.start_arg"></a> `start-arg`: handle<start-arg>
2831
##### Results
2932

30-
- [`api-type-one`](#api_type_one)
33+
- result<[`thread-id`](#thread_id), [`errno`](#errno)>
3134

proposal-template.wit.md

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,41 @@
1-
# [Proposal Template] API
1+
# WASI threads API
22

3-
[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!).]
3+
WASI threads is an API for thread creation.
44

5-
[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.]
5+
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.
66

7-
[If you want to include examples of the API in use, these should be in the README and linked to from this file.]
87

9-
## api_type_one
8+
## thread-id
109

1110
```wit
12-
/// Short description
13-
///
14-
/// Explanation for developers using the API.
15-
record api-type-one {
16-
property1: u64,
17-
property2: string,
18-
}
11+
/// Unique thread identifier.
12+
type thread-id = u32
1913
```
2014

21-
More rigorous specification details for the implementer go here, if needed.
15+
## start-arg
16+
17+
```wit
18+
/// A reference to data passed to the start function (`wasi_thread_start()`) called by the newly spawned thread.
19+
resource start-arg {
20+
}
21+
```
2222

23-
## api_function_one
23+
## errno
2424

2525
```wit
26-
/// Short description
27-
///
28-
/// Explanation for developers using the API.
29-
api-function-one: func() -> api-type-one
26+
/// Error codes returned by the `thread-spawn` function.
27+
enum errno {
28+
/// TBD
29+
eagain,
30+
}
3031
```
3132

32-
If needed, this would explain what a compliant implementation MUST do, such as never returning an earlier result from a later call.
33+
## thread_spawn
34+
35+
```wit
36+
/// Creates a new thread.
37+
thread-spawn: func(
38+
/// A value being passed to a start function (`wasi_thread_start()`).
39+
start-arg: start-arg,
40+
) -> result<thread-id, errno>
41+
```

0 commit comments

Comments
 (0)