Add example with multiple threads creation#1826
Add example with multiple threads creation#1826eloparco wants to merge 1 commit intobytecodealliance:dev/wasi_threadsfrom
Conversation
|
FYI, there are a few test efforts: |
|
|
||
| printf("Created thread with id = %d\n", thread_id); | ||
| assert(thread_id == thread_ids[0] | ||
| && "New thread must reuse previously-released identifier"); |
There was a problem hiding this comment.
- it seems racy as the first thread might be still running
- i'm not sure if it's a good idea to test this kind of implementation details (how ids are reused) in these samples.
There was a problem hiding this comment.
Not sure about the race condition, but I definitely agree that the check on the id is an implementation detail and should not be tested.
There was a problem hiding this comment.
What's unsafe is maybe that, after __builtin_wasm_memory_atomic_wait32() in the main thread, I can't assume that the thread created has finished and it's possible to create a new thread.
|
I wonder if we actually need this example as it doesn't present any new feature that's already not in |
|
It's to test the failure and re-attempt on thread creation once the thread number limit is reached. Probably it doesn't add anything, I'll close the PR |
The example shows the creation of multiple threads. Thread spawn failure and thread identifier allocation are tested.
Now written as an example, it uses asserts so that it can be easily converted into a test once a test suite is created #1790.