| 285 | // ... |
| 286 | SC_TRY(eventLoop.run()); |
| 287 | // ... |
| 288 | // Here all AsyncRequest have either finished or have been stopped |
| 289 | // ... |
| 290 | SC_TRY(eventLoop.close()); // Free OS specific queue handles |
| 291 | //! [AsyncEventLoopSnippet] |
| 292 | return Result(true); |
| 293 | } |
| 294 | |
| 295 | SC::Result snippetForTimeout(AsyncEventLoop& eventLoop, Console& console) |
| 296 | { |
| 297 | bool someCondition = false; |
| 298 | //! [AsyncLoopTimeoutSnippet] |
| 299 | // Create a timeout that will be called after 200 milliseconds |
| 300 | // AsyncLoopTimeout must be valid until callback is called |
| 301 | AsyncLoopTimeout timeout; |
| 302 | timeout.callback = [&](AsyncLoopTimeout::Result& res) |
| 303 | { |
| 304 | console.print("My timeout has been called!"); |
| 305 | if (someCondition) // Optionally re-activate the timeout if needed |
| 306 | { |
| 307 | // Schedule the timeout callback to fire again 100 ms from now |
| 308 | res.getAsync().relativeTimeout = Time::Milliseconds(100); |
| 309 | res.reactivateRequest(true); |
| 310 | } |
| 311 | }; |
| 312 | // Start the timeout, that will be called 200 ms from now |
nothing calls this directly
no test coverage detected