|
@@ -878,6 +878,11 @@ bool Engine::hasModule(Module* module) { |
|
|
|
|
|
|
|
|
Module* Engine::getModule(int64_t moduleId) { |
|
|
Module* Engine::getModule(int64_t moduleId) { |
|
|
ReadLock lock(internal->mutex); |
|
|
ReadLock lock(internal->mutex); |
|
|
|
|
|
return getModule_NoLock(moduleId); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Module* Engine::getModule_NoLock(int64_t moduleId) { |
|
|
auto it = internal->modulesCache.find(moduleId); |
|
|
auto it = internal->modulesCache.find(moduleId); |
|
|
if (it == internal->modulesCache.end()) |
|
|
if (it == internal->modulesCache.end()) |
|
|
return NULL; |
|
|
return NULL; |
|
@@ -1153,6 +1158,11 @@ void Engine::removeParamHandle_NoLock(ParamHandle* paramHandle) { |
|
|
|
|
|
|
|
|
ParamHandle* Engine::getParamHandle(int64_t moduleId, int paramId) { |
|
|
ParamHandle* Engine::getParamHandle(int64_t moduleId, int paramId) { |
|
|
ReadLock lock(internal->mutex); |
|
|
ReadLock lock(internal->mutex); |
|
|
|
|
|
return getParamHandle_NoLock(moduleId, paramId); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ParamHandle* Engine::getParamHandle_NoLock(int64_t moduleId, int paramId) { |
|
|
auto it = internal->paramHandlesCache.find(std::make_tuple(moduleId, paramId)); |
|
|
auto it = internal->paramHandlesCache.find(std::make_tuple(moduleId, paramId)); |
|
|
if (it == internal->paramHandlesCache.end()) |
|
|
if (it == internal->paramHandlesCache.end()) |
|
|
return NULL; |
|
|
return NULL; |
|
@@ -1166,7 +1176,12 @@ ParamHandle* Engine::getParamHandle(Module* module, int paramId) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Engine::updateParamHandle(ParamHandle* paramHandle, int64_t moduleId, int paramId, bool overwrite) { |
|
|
void Engine::updateParamHandle(ParamHandle* paramHandle, int64_t moduleId, int paramId, bool overwrite) { |
|
|
ReadLock lock(internal->mutex); |
|
|
|
|
|
|
|
|
WriteLock lock(internal->mutex); |
|
|
|
|
|
updateParamHandle_NoLock(paramHandle, moduleId, paramId, overwrite); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Engine::updateParamHandle_NoLock(ParamHandle* paramHandle, int64_t moduleId, int paramId, bool overwrite) { |
|
|
// Check that it exists |
|
|
// Check that it exists |
|
|
auto it = internal->paramHandles.find(paramHandle); |
|
|
auto it = internal->paramHandles.find(paramHandle); |
|
|
assert(it != internal->paramHandles.end()); |
|
|
assert(it != internal->paramHandles.end()); |
|
@@ -1179,8 +1194,7 @@ void Engine::updateParamHandle(ParamHandle* paramHandle, int64_t moduleId, int p |
|
|
|
|
|
|
|
|
if (paramHandle->moduleId >= 0) { |
|
|
if (paramHandle->moduleId >= 0) { |
|
|
// Replace old ParamHandle, or reset the current ParamHandle |
|
|
// Replace old ParamHandle, or reset the current ParamHandle |
|
|
// TODO Maybe call getParamHandle_NoLock()? |
|
|
|
|
|
ParamHandle* oldParamHandle = getParamHandle(moduleId, paramId); |
|
|
|
|
|
|
|
|
ParamHandle* oldParamHandle = getParamHandle_NoLock(moduleId, paramId); |
|
|
if (oldParamHandle) { |
|
|
if (oldParamHandle) { |
|
|
if (overwrite) { |
|
|
if (overwrite) { |
|
|
oldParamHandle->moduleId = -1; |
|
|
oldParamHandle->moduleId = -1; |
|
@@ -1197,8 +1211,7 @@ void Engine::updateParamHandle(ParamHandle* paramHandle, int64_t moduleId, int p |
|
|
|
|
|
|
|
|
// Set module pointer if the above block didn't reset it |
|
|
// Set module pointer if the above block didn't reset it |
|
|
if (paramHandle->moduleId >= 0) { |
|
|
if (paramHandle->moduleId >= 0) { |
|
|
// TODO Maybe call getModule_NoLock()? |
|
|
|
|
|
paramHandle->module = getModule(paramHandle->moduleId); |
|
|
|
|
|
|
|
|
paramHandle->module = getModule_NoLock(paramHandle->moduleId); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Engine_refreshParamHandleCache(this); |
|
|
Engine_refreshParamHandleCache(this); |
|
|