[core] Follow-up on the platform integration callback PR

Addressing review comments that arrived after the PR was merged.
This commit is contained in:
Thiago Marcos P. Santos
2020-03-12 00:28:45 +02:00
parent 639434b3ef
commit 461c414748

View File

@@ -48,14 +48,12 @@ public:
void runOnce();
void stop();
using PlatformCallback = std::function<void()>;
// Platform integration callback for platforms that do not have full
// run loop integration or don't want to block at the Mapbox GL Native
// loop. It will be called from any thread and is up to the platform
// to, after receiving the callback, call RunLoop::runOnce() from the
// same thread as the Map object lives.
void setPlatformCallback(PlatformCallback&& callback) { platformCallback = std::move(callback); }
void setPlatformCallback(std::function<void()> callback) { platformCallback = std::move(callback); }
// So far only needed by the libcurl backend.
void addWatch(int fd, Event, std::function<void(int, Event)>&& callback);
@@ -104,7 +102,10 @@ private:
defaultQueue.emplace(std::move(task));
}
wake();
platformCallback();
if (platformCallback) {
platformCallback();
}
}
void process() {
@@ -127,7 +128,7 @@ private:
}
}
PlatformCallback platformCallback = [] {};
std::function<void()> platformCallback;
Queue defaultQueue;
Queue highPriorityQueue;