Files
MapLibreParticleLab/platform/android/MapboxGLAndroidSDK/src/cpp/map_renderer_runnable.hpp
fynngodau c75e3596da Change Android package and class names away from mapbox (#1201)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Bart Louwers <bart@emeel.net>
2023-06-12 14:04:25 +02:00

45 lines
1.0 KiB
C++

#pragma once
#include <mbgl/actor/mailbox.hpp>
#include <mbgl/actor/scheduler.hpp>
#include <memory>
#include <utility>
#include <jni/jni.hpp>
namespace mbgl {
namespace android {
/**
* The MapRendererRunnable is a peer class that encapsulates
* a scheduled mailbox in a Java Runnable so it can be
* scheduled on the map renderer thread.
*
*/
class MapRendererRunnable {
public:
static constexpr auto Name() { return "org/maplibre/android/maps/renderer/MapRendererRunnable"; };
static void registerNative(jni::JNIEnv&);
MapRendererRunnable(jni::JNIEnv&, std::function<void()>);
// Only for jni registration, unused
MapRendererRunnable(jni::JNIEnv&) { assert(false); }
~MapRendererRunnable();
void run(jni::JNIEnv&);
// Transfers ownership of the Peer object to the caller
jni::Global<jni::Object<MapRendererRunnable>> peer();
private:
jni::Global<jni::Object<MapRendererRunnable>> javaPeer;
std::function<void()> function;
};
} // namespace android
} // namespace mbgl