[core] Fix RunLoop::run() behavior when called a second time

This commit is contained in:
John Firebaugh
2016-03-08 09:29:44 -08:00
parent aaf9e8256f
commit 8fee0f33c0
2 changed files with 22 additions and 0 deletions

View File

@@ -151,6 +151,7 @@ void RunLoop::push(std::shared_ptr<WorkTask> task) {
void RunLoop::run() {
MBGL_VERIFY_THREAD(tid);
uv_ref(impl->holderHandle());
uv_run(impl->loop, UV_RUN_DEFAULT);
}

View File

@@ -29,3 +29,24 @@ TEST(RunLoop, MultipleStop) {
loop.run();
}
TEST(RunLoop, MultipleRun) {
RunLoop loop(RunLoop::Type::New);
Timer timer;
timer.start(mbgl::Duration::zero(), mbgl::Duration::zero(), [&] {
loop.stop();
});
loop.run();
bool secondTimeout = false;
timer.start(mbgl::Duration::zero(), mbgl::Duration::zero(), [&] {
secondTimeout = true;
loop.stop();
});
loop.run();
EXPECT_TRUE(secondTimeout);
}