| 104 | } |
| 105 | |
| 106 | void Queue::Sync(Thunk&& thunk) { |
| 107 | std::mutex m; |
| 108 | std::condition_variable cv; |
| 109 | std::unique_lock<std::mutex> l(m); |
| 110 | std::exception_ptr e; |
| 111 | bool done = false; |
| 112 | DoInvoke([&]{ |
| 113 | std::unique_lock<std::mutex> l(m); |
| 114 | try { |
| 115 | thunk(); |
| 116 | } |
| 117 | catch (...) { |
| 118 | e = std::current_exception(); |
| 119 | } |
| 120 | done = true; |
| 121 | cv.notify_all(); |
| 122 | }); |
| 123 | cv.wait(l, [&]{ return done; }); |
| 124 | if (e) std::rethrow_exception(e); |
| 125 | } |
| 126 | |
| 127 | Queue& Main() { |
| 128 | static MainQueue q; |
no outgoing calls
no test coverage detected