Thread safety
This commit is contained in:
parent
f12a8dbe20
commit
1b111f0313
|
@ -111,6 +111,8 @@ XModule* KernelState::GetModule(const char* name) {
|
||||||
// Some games request this, for some reason. wtf.
|
// Some games request this, for some reason. wtf.
|
||||||
return nullptr;
|
return nullptr;
|
||||||
} else {
|
} else {
|
||||||
|
std::lock_guard<std::mutex> lock(object_mutex_);
|
||||||
|
|
||||||
for (XUserModule *module : user_modules_) {
|
for (XUserModule *module : user_modules_) {
|
||||||
if (module->name() == name) {
|
if (module->name() == name) {
|
||||||
module->Retain();
|
module->Retain();
|
||||||
|
@ -146,6 +148,8 @@ void KernelState::SetExecutableModule(XUserModule* module) {
|
||||||
}
|
}
|
||||||
|
|
||||||
XUserModule* KernelState::LoadUserModule(const char *name) {
|
XUserModule* KernelState::LoadUserModule(const char *name) {
|
||||||
|
std::lock_guard<std::mutex> lock(object_mutex_);
|
||||||
|
|
||||||
// See if we've already loaded it
|
// See if we've already loaded it
|
||||||
for (XUserModule *module : user_modules_) {
|
for (XUserModule *module : user_modules_) {
|
||||||
if (module->name() == name) {
|
if (module->name() == name) {
|
||||||
|
@ -158,7 +162,7 @@ XUserModule* KernelState::LoadUserModule(const char *name) {
|
||||||
XUserModule *module = new XUserModule(this, name);
|
XUserModule *module = new XUserModule(this, name);
|
||||||
X_STATUS status = module->LoadFromFile(name);
|
X_STATUS status = module->LoadFromFile(name);
|
||||||
if (XFAILED(status)) {
|
if (XFAILED(status)) {
|
||||||
delete module;
|
module->Release();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue