[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:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user