Closed jonesmz closed 1 year ago
Hm, couldn't you use mainLoopIteration()
directly in that case? Completely with your own main()
as well, since the MAGNUM_APPLICATION_MAIN()
calls exec()
.
There's a lot of use cases where exec()
isn't flexible enough and that's why mainLoopIteration()
is exposed as a separate, lower-level API -- you're not required to call it, and you're not required to use the MAGNUM_APPLICATION_MAIN()
macro either. The only bit of friction is on Emscripten, but there you can't reliably use threads anyway (and IIRC, OSP doesn't have a web build at the moment?).
Not planned, use mainLoopIteration()
directly instead.
See: https://en.cppreference.com/w/cpp/thread/stop_token
And Sdl2Application::exec() is implemented as follows:
It would be nice, if Magnum was compiled with C++20, to have the ability to pass an std::stop_token into the exec() function as an additional way to terminate.
This would be an alternative to calling Sdl2Application::exit();
The motivation behind this feature request is to support slightly better encapsulation, where an application that has a threadpool, holding one or more
std::jthread
objects may not want to have the threadpool code aware of special rules to shutdown the threads, allowing instead for the std::stop_token to be respected directly for a pool-wide graceful shutdown.