| 327 | } |
| 328 | |
| 329 | SC::Result snippetForWakeUp2(AsyncEventLoop& eventLoop, Console& console) |
| 330 | { |
| 331 | //! [AsyncLoopWakeUpSnippet2] |
| 332 | // Assuming an already created (and running) AsyncEventLoop named eventLoop |
| 333 | // ... |
| 334 | // This code runs on some different thread from the one calling SC::AsyncEventLoop::run. |
| 335 | // The callback is invoked from the thread calling SC::AsyncEventLoop::run |
| 336 | AsyncLoopWakeUp wakeUpWaiting; // Memory lifetime must be valid until callback is called |
| 337 | wakeUpWaiting.callback = [&](AsyncLoopWakeUp::Result& result) |
| 338 | { |
| 339 | console.print("My wakeUp has been called!"); |
| 340 | result.reactivateRequest(true); // To allow waking-up it again later |
| 341 | }; |
| 342 | EventObject eventObject; |
| 343 | SC_TRY(wakeUpWaiting.start(eventLoop, eventObject)); |
| 344 | eventObject.wait(); // Wait until callback has been fully run inside event loop thread |
| 345 | // From here on we know for sure that callback has been called |
| 346 | //! [AsyncLoopWakeUpSnippet2] |
| 347 | return Result(true); |
| 348 | } |
| 349 | |
| 350 | SC::Result snippetForProcess(AsyncEventLoop& eventLoop, Console& console) |
| 351 | { |
nothing calls this directly
no test coverage detected