sonar | Replace global static variables within jni/sonar.cpp with local static.
Summary: Replacing global static varaibles with local static. No cost at startup time, and also fixes any potential static initialization order fiasco. Differential Revision: D45900844 fbshipit-source-id: 4ff05cbefe2f0c00199f40b9127e28c355d1819e
This commit is contained in:
committed by
Facebook GitHub Bot
parent
0069155b1e
commit
b66bff3837
@@ -44,8 +44,15 @@ void handleException(const std::exception& e) {
|
||||
__android_log_write(ANDROID_LOG_ERROR, "FLIPPER", message.c_str());
|
||||
}
|
||||
|
||||
std::unique_ptr<facebook::flipper::Scheduler> sonarScheduler;
|
||||
std::unique_ptr<facebook::flipper::Scheduler> connectionScheduler;
|
||||
std::unique_ptr<facebook::flipper::Scheduler>& sonarScheduler() {
|
||||
static std::unique_ptr<facebook::flipper::Scheduler> scheduler;
|
||||
return scheduler;
|
||||
}
|
||||
|
||||
std::unique_ptr<facebook::flipper::Scheduler>& connectionScheduler() {
|
||||
static std::unique_ptr<facebook::flipper::Scheduler> scheduler;
|
||||
return scheduler;
|
||||
}
|
||||
|
||||
class JEventBase : public jni::HybridClass<JEventBase> {
|
||||
public:
|
||||
@@ -943,9 +950,9 @@ class JFlipperClient : public jni::HybridClass<JFlipperClient> {
|
||||
const std::string app,
|
||||
const std::string appId,
|
||||
const std::string privateAppDirectory) {
|
||||
sonarScheduler =
|
||||
sonarScheduler() =
|
||||
std::make_unique<FollyScheduler>(callbackWorker->eventBase());
|
||||
connectionScheduler =
|
||||
connectionScheduler() =
|
||||
std::make_unique<FollyScheduler>(connectionWorker->eventBase());
|
||||
|
||||
FlipperClient::init(
|
||||
@@ -956,8 +963,8 @@ class JFlipperClient : public jni::HybridClass<JFlipperClient> {
|
||||
std::move(app),
|
||||
std::move(appId),
|
||||
std::move(privateAppDirectory)},
|
||||
sonarScheduler.get(),
|
||||
connectionScheduler.get(),
|
||||
sonarScheduler().get(),
|
||||
connectionScheduler().get(),
|
||||
insecurePort,
|
||||
securePort,
|
||||
altInsecurePort,
|
||||
|
||||
Reference in New Issue
Block a user