[android] Do not create Timers on Default main loops

Not supported, because we don't have control over the Looper
timeout like we do for Loopers we create. On the main thread,
Android takes care of making the application sleep and sets
an arbitrary timeout. This could be properly fixed by implementing
timers in Java, but we don't really have the use case of timers
in the main thread.
This commit is contained in:
Thiago Marcos P. Santos
2016-07-04 20:23:49 +03:00
parent b3b86f9be4
commit 13cd75f099
4 changed files with 12 additions and 7 deletions

View File

@@ -3,6 +3,7 @@
#include <mbgl/util/run_loop.hpp>
#include <mbgl/util/timer.hpp>
#include <cassert>
#include <functional>
namespace mbgl {
@@ -11,6 +12,7 @@ namespace util {
class Timer::Impl : public RunLoop::Impl::Runnable {
public:
Impl() {
assert(!loop->isDefaultLoop);
loop->initRunnable(this);
}
@@ -35,7 +37,7 @@ public:
void reschedule() {
if (repeat != Duration::zero()) {
due = Clock::now() + repeat;
loop->addRunnable(this);
loop->wake();
} else {
stop();
}