-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGriffinTools.cpp
49 lines (35 loc) · 1.07 KB
/
GriffinTools.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#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