Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/test/embind/test_pthreads.cpp
4150 views
1
#include <assert.h>
2
#include <emscripten.h>
3
#include <emscripten/val.h>
4
#include <string>
5
#include <thread>
6
7
using namespace emscripten;
8
9
void thread(void) {
10
EM_ASM({
11
globalProperty = {
12
foo: function(value) {
13
return value;
14
}
15
};
16
});
17
val globalProperty = val::global("globalProperty");
18
auto result0 = globalProperty.call<val>("foo", val("bar"));
19
assert(result0.as<std::string>() == "bar");
20
}
21
22
int main() {
23
std::thread t(thread);
24
std::thread t1(thread);
25
t.join();
26
t1.join();
27
return 0;
28
}
29
30