MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / notify

Function notify

test/pthread/test_pthread_reltime.cpp:40–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38
39EMSCRIPTEN_KEEPALIVE
40extern "C" int notify() {
41 {
42 std::unique_lock<std::mutex> lock(mutex);
43 std::cout << "notifying ..." << std::endl;
44 ping = now();
45 pong_requested = true;
46 cond_var.notify_one();
47 }
48
49 {
50 std::unique_lock<std::mutex> lock(mutex);
51 while (pong_requested)
52 cond_var.wait(lock);
53 long last = now();
54 std::cout << "last - pong: " << (last - ping) << std::endl;
55
56 // Time measured on a worker should be relative to the main thread,
57 // so that things are basically monotonic.
58 assert((int(pong >= ping) + 2 * int(last >= pong)) == 3);
59 emscripten_force_exit(0);
60 }
61
62 return 0;
63}
64
65int main() {
66 std::cout << "running main ..." << std::endl;

Callers

nothing calls this directly

Calls 4

nowFunction · 0.85
assertFunction · 0.50
notify_oneMethod · 0.45
waitMethod · 0.45

Tested by

no test coverage detected