Skip to content

Instantly share code, notes, and snippets.

@Constellation
Created April 14, 2016 05:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Constellation/e27d023de983af2cee917200b10c34e6 to your computer and use it in GitHub Desktop.
Save Constellation/e27d023de983af2cee917200b10c34e6 to your computer and use it in GitHub Desktop.
TEST(WTF_RunLoop, ManyTimes)
{
RunLoop::initializeMainRunLoop();
class Counter {
public:
void run()
{
if (++m_count == 100000000) {
RunLoop::current().stop();
return;
}
RunLoop::current().dispatch([this] {
run();
});
}
private:
unsigned m_count { 0 };
};
Counter counter;
RunLoop::current().dispatch([&counter] {
counter.run();
});
RunLoop::run();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment