-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Add multithreaded variant to ICU port #15592
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
Conversation
tests/other/test_pthread_icu.cpp
Outdated
ustr.toUTF8String(str); | ||
std::cout << str << std::endl; | ||
}).detach(); | ||
} |
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.
Add newline and EOF
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.
lgtm % comments
tests/other/test_pthread_icu.cpp
Outdated
|
||
// Test that code using both pthread and icu compiles. | ||
int main () { | ||
std::thread([] { |
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.
I know we are not yet consistent, but we are trying to use a consistent style these days which involves 2-space indentation (we have a .clang-format file if you want to just use that)
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.
Sure. Can I recommend mentioning the existence of a style convention in Contributing or Developer's Guide?
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.
Yes we should do that.
tests/test_other.py
Outdated
@@ -11125,6 +11125,10 @@ def test_pthread_out_err(self): | |||
self.set_setting('EXIT_RUNTIME') | |||
self.do_other_test('test_pthread_out_err.c') | |||
|
|||
@node_pthreads | |||
def test_icu_mt(self): |
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.
Can you name the test the same as the file, i.e def test_pthread_icu
?
tests/test_other.py
Outdated
@@ -11125,6 +11125,10 @@ def test_pthread_out_err(self): | |||
self.set_setting('EXIT_RUNTIME') | |||
self.do_other_test('test_pthread_out_err.c') | |||
|
|||
@node_pthreads | |||
def test_icu_mt(self): | |||
self.do_smart_test(test_file('other/test_pthread_icu.cpp'), emcc_args=['-pthread', '-sUSE_ICU', '-sPTHREAD_POOL_SIZE_STRICT=4', '-sEXIT_RUNTIME']) |
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.
Looks like do_other_test
(like the test above) should suffice.
tests/other/test_pthread_icu.cpp
Outdated
icu::UnicodeString ustr("Hello world!"); | ||
ustr.toUTF8String(str); | ||
std::cout << str << std::endl; | ||
}).detach(); |
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.
Better to .join
here since emscripten doesn't handling the case where the main application thread exits while other threads are still running.
Probably best to use PROXY_TO_PTHREAD
and drop PTHREAD_POOL_SIZE_STRICT
I wonder if we can perhaps just always build with pthread enabled since browser should accept atomic opcode in single-threaded programs these days. See WebAssembly/threads#144 @tlively WDTY? |
Certain browsers do not support atomics: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics |
Yeah, I think Safari still does not support atomics yet (according to https://webassembly.org/roadmap/), so it's probably best not to enable threads by default :( |
Fixes #14518