commit 8533bb95d36c0d21ee26d79b02ab14dff16de856
parent 9341f5ee7d69f4199a5f5d1e36a361bb4e369188
Author: rhunk <101876869+rhunk@users.noreply.github.com>
Date: Wed, 1 May 2024 01:31:50 +0200
perf(native): startup time
Diffstat:
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/native/jni/src/library.cpp b/native/jni/src/library.cpp
@@ -2,6 +2,7 @@
#include <string>
#include <dobby.h>
#include <vector>
+#include <thread>
#include "logger.h"
#include "common.h"
@@ -29,12 +30,20 @@ bool JNICALL init(JNIEnv *env, jobject clazz) {
LOGD("client_module offset=0x%lx, size=0x%zx", client_module.base, client_module.size);
- UnaryCallHook::init(env);
- FstatHook::init();
- SqliteMutexHook::init();
- DuplexHook::init(env);
+ auto threads = std::vector<std::thread>();
+
+ #define RUN(body) threads.push_back(std::thread([&] { body; }))
+
+ RUN(UnaryCallHook::init(env));
+ RUN(FstatHook::init());
+ RUN(SqliteMutexHook::init());
+ RUN(DuplexHook::init(env));
if (common::native_config->composer_hooks) {
- ComposerHook::init();
+ RUN(ComposerHook::init());
+ }
+
+ for (auto &thread : threads) {
+ thread.join();
}
LOGD("Native initialized");