Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
49 lines (35 sloc) 1.07 KB
#include <tools/GriffinTools.h>
#include <future>
#include <application/platform.h>
#include <utility/Logger.h>
#ifdef GRIFFIN_TOOLS_BUILD
namespace griffin {
namespace tools {
// class GriffinTools
GriffinToolsManager::~GriffinToolsManager()
{
m_done = true;
m_toolsThread.wait();
}
void GriffinToolsManager::init(const script::ScriptManagerPtr& scriptPtr)
{
m_toolsThread = std::async(std::launch::async, [this, scriptPtr]() {
// build lua files (resolve #includes, copy to data script path)
scriptPtr->doFile(m_toolsLuaStateId, "scripts/luaBuild.lua");
// start the tools http server
scriptPtr->doFile(m_toolsLuaStateId, "scripts/tools/ToolsServer.lua");
scriptPtr->callLuaGlobalFunction(m_toolsLuaStateId, "initToolsServer");
while (!m_done) {
try {
scriptPtr->callLuaGlobalFunction(m_toolsLuaStateId, "frameToolsHandler");
}
catch (std::exception ex) {
logger.warn(Logger::Category_Error, "tools server exception: %s", ex.what());
}
platform::yieldThread();
}
});
}
}
}
#endif
You can’t perform that action at this time.