Я пересоздал репозиторий из-за большого количества мусора в прошлом

This commit is contained in:
Jiga228
2025-09-14 15:00:44 +07:00
commit 78a25b305b
74 changed files with 3428 additions and 0 deletions
+68
View File
@@ -0,0 +1,68 @@
#include "ModuleInstance.h"
#include <mutex>
#include <thread>
ModuleInstance::ModuleInstance(CoreInstance& core) : core_(core)
{
// Init instance
}
void ModuleInstance::start()
{
// Create thread
}
void ModuleInstance::stop()
{
onStop.Call();
}
extern ModuleInstance* Factory(CoreInstance&);
static std::mutex mModuleInstance;
static ModuleInstance* module = nullptr;
static std::thread* moduleThread;
void InitModule(CoreInstance& core)
{
mModuleInstance.lock();
if(module == nullptr)
module = Factory(core);
mModuleInstance.unlock();
}
void StartModule()
{
mModuleInstance.lock();
if (module != nullptr)
moduleThread = new std::thread([&] {module->start(); });
mModuleInstance.unlock();
}
void StopModule()
{
mModuleInstance.lock();
if(module != nullptr)
{
delete module;
module = nullptr;
moduleThread->detach();
delete moduleThread;
}
mModuleInstance.unlock();
}
void QuitModule()
{
mModuleInstance.lock();
if(module != nullptr)
{
module->stop();
moduleThread->join();
delete module;
module = nullptr;
}
mModuleInstance.unlock();
}