mirror of
https://github.com/Takiiiiiiii/strato.git
synced 2025-07-17 08:46:39 +00:00
Complete making the kernel thread-safe #2 + Fix Shared Memory Implementation
This commit makes the kernel completely thread-safe and fixes an issue that caused libNX games to not work due to an error with KSharedMemory. In addition, implement GroupMutex to allow the kernel threads to run in parallel but still allow them to not overlap with the JNI thread.
This commit is contained in:
@ -5,21 +5,21 @@ thread_local JNIEnv *env;
|
||||
namespace skyline {
|
||||
JvmManager::JvmManager(JNIEnv *environ, jobject instance) : instance(instance), instanceClass(reinterpret_cast<jclass>(environ->NewGlobalRef(environ->GetObjectClass(instance)))) {
|
||||
env = environ;
|
||||
if(env->GetJavaVM(&vm) < 0)
|
||||
if (env->GetJavaVM(&vm) < 0)
|
||||
throw exception("Cannot get JavaVM from environment");
|
||||
}
|
||||
|
||||
void JvmManager::AttachThread() {
|
||||
if(!env)
|
||||
if (!env)
|
||||
vm->AttachCurrentThread(&env, nullptr);
|
||||
}
|
||||
|
||||
void JvmManager::DetachThread() {
|
||||
if(env)
|
||||
if (env)
|
||||
vm->DetachCurrentThread();
|
||||
}
|
||||
|
||||
JNIEnv* JvmManager::GetEnv() {
|
||||
JNIEnv *JvmManager::GetEnv() {
|
||||
return env;
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ namespace skyline {
|
||||
return env->IsSameObject(env->GetObjectField(instance, env->GetFieldID(instanceClass, key, signature)), nullptr);
|
||||
}
|
||||
|
||||
bool JvmManager::CheckNull(jobject& object) {
|
||||
bool JvmManager::CheckNull(jobject &object) {
|
||||
return env->IsSameObject(object, nullptr);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user