Android/core: Couple a sequenced scheduler to the lifetime of a GeoJSON source (#2182)

This commit is contained in:
mwilsnd
2024-03-11 12:49:37 -04:00
committed by GitHub
parent 25678a4d99
commit 4e9392ee29
6 changed files with 23 additions and 30 deletions

View File

@@ -245,7 +245,8 @@ void FeatureConverter::convertJson(std::shared_ptr<std::string> json, ActorRef<G
return;
}
callback.invoke(&GeoJSONDataCallback::operator(), style::GeoJSONData::create(*converted, options));
callback.invoke(&GeoJSONDataCallback::operator(),
style::GeoJSONData::create(*converted, sequencedScheduler, options));
}
template <class JNIType>
@@ -257,7 +258,8 @@ void FeatureConverter::convertObject(
android::UniqueEnv _env = android::AttachEnv();
// Convert the jni object
auto geometry = JNIType::convert(*_env, *jObject);
callback.invoke(&GeoJSONDataCallback::operator(), style::GeoJSONData::create(geometry, options));
callback.invoke(&GeoJSONDataCallback::operator(),
style::GeoJSONData::create(geometry, sequencedScheduler, options));
}
Update::Update(Converter _converterFn, std::unique_ptr<Actor<GeoJSONDataCallback>> _callback)

View File

@@ -16,7 +16,8 @@ using GeoJSONDataCallback = std::function<void(std::shared_ptr<style::GeoJSONDat
class FeatureConverter {
public:
explicit FeatureConverter(Immutable<style::GeoJSONOptions> options_)
: options(std::move(options_)) {}
: options(std::move(options_)),
sequencedScheduler(Scheduler::GetSequenced()) {}
void convertJson(std::shared_ptr<std::string>, ActorRef<GeoJSONDataCallback>);
template <class JNIType>
@@ -25,6 +26,7 @@ public:
private:
Immutable<style::GeoJSONOptions> options;
std::shared_ptr<Scheduler> sequencedScheduler;
};
struct Update {