| 2104 | { |
| 2105 | public: |
| 2106 | Future<Nothing> wait_for_terminate(Promise<Nothing>&& p) |
| 2107 | { |
| 2108 | p.set(Nothing()); // Notify that we're inside the function. |
| 2109 | |
| 2110 | Time start = Clock::now(); |
| 2111 | |
| 2112 | while (Clock::now() - start < process::TEST_AWAIT_TIMEOUT) { |
| 2113 | if (eventCount<TerminateEvent>() == 1 && |
| 2114 | eventCount<DispatchEvent>() == 1) { |
| 2115 | return Nothing(); |
| 2116 | } |
| 2117 | |
| 2118 | os::sleep(Milliseconds(1)); |
| 2119 | } |
| 2120 | |
| 2121 | return Failure("Timed out waiting for terminate and dispatch"); |
| 2122 | } |
| 2123 | }; |
| 2124 | |
| 2125 | PID<TestProcess> process = spawn(new TestProcess(), true); |