| 38 | |
| 39 | EMSCRIPTEN_KEEPALIVE |
| 40 | extern "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 | |
| 65 | int main() { |
| 66 | std::cout << "running main ..." << std::endl; |
nothing calls this directly
no test coverage detected