-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Move setting of initial thread state to native code. NFC #15533
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -116,6 +116,12 @@ int __pthread_create(pthread_t* restrict res, | |
| new->tsd = malloc(PTHREAD_KEYS_MAX * sizeof(void*)); | ||
| memset(new->tsd, 0, PTHREAD_KEYS_MAX * sizeof(void*)); | ||
|
|
||
| if (attrp && attrp != __ATTRP_C11_THREAD && attrp->_a_detach) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This logic looks different than before - it also checks
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The old code is doing the same thing is just a little harder to read:
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, right, I see it now. |
||
| new->detach_state = DT_DETACHED; | ||
| } else { | ||
| new->detach_state = DT_JOINABLE; | ||
| } | ||
|
|
||
| //printf("start __pthread_create: %p\n", self); | ||
| int rtn = __pthread_create_js(new, attrp, entry, arg); | ||
| if (rtn != 0) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not leave this assertion?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing this means the JS has no more need to know about detach_state (keeping the logic all in native code simplifies the model IMHO). Also, detachedExit has exactly one callsite which is in emscripten_thread_exit so it seems little unnecessary. I think it will be good if in the long run we can move all the threadInfoStruct handling to native code and reduce the JS code to just worker handling.