MCPcopy Create free account
hub / github.com/VCVRack/Rack / addModule_NoLock

Method addModule_NoLock

src/engine/Engine.cpp:762–788  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

760
761
762void Engine::addModule_NoLock(Module* module) {
763 assert(module);
764 // Check that the module is not already added
765 auto it = std::find(internal->modules.begin(), internal->modules.end(), module);
766 assert(it == internal->modules.end());
767 // Set ID if unset or collides with an existing ID
768 while (module->id < 0 || internal->modulesCache.find(module->id) != internal->modulesCache.end()) {
769 // Randomly generate ID
770 module->id = random::u64() % (1ull << 53);
771 }
772 // Add module
773 internal->modules.push_back(module);
774 internal->modulesCache[module->id] = module;
775 // Dispatch AddEvent
776 Module::AddEvent eAdd;
777 module->onAdd(eAdd);
778 // Dispatch SampleRateChangeEvent
779 Module::SampleRateChangeEvent eSrc;
780 eSrc.sampleRate = internal->sampleRate;
781 eSrc.sampleTime = internal->sampleTime;
782 module->onSampleRateChange(eSrc);
783 // Update ParamHandles' module pointers
784 for (ParamHandle* paramHandle : internal->paramHandles) {
785 if (paramHandle->moduleId == module->id)
786 paramHandle->module = module;
787 }
788}
789
790
791void Engine::removeModule(Module* module) {

Callers

nothing calls this directly

Calls 4

findFunction · 0.85
u64Function · 0.85
onAddMethod · 0.45
onSampleRateChangeMethod · 0.45

Tested by

no test coverage detected