comparison Core/Lua/LuaContext.cpp @ 996:cf52f3bcb2b3 lua-scripting

clarification of Lua classes wrt multithreading
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 03 Jul 2014 16:27:16 +0200
parents a811bdf8b8eb
children b067017a8a5b
comparison
equal deleted inserted replaced
995:8c67382f44a7 996:cf52f3bcb2b3
32 32
33 #include "../PrecompiledHeaders.h" 33 #include "../PrecompiledHeaders.h"
34 #include "LuaContext.h" 34 #include "LuaContext.h"
35 35
36 #include <glog/logging.h> 36 #include <glog/logging.h>
37 #include <cassert>
37 38
38 extern "C" 39 extern "C"
39 { 40 {
40 #include <lualib.h> 41 #include <lualib.h>
41 #include <lauxlib.h> 42 #include <lauxlib.h>
109 110
110 111
111 void LuaContext::Execute(std::string* output, 112 void LuaContext::Execute(std::string* output,
112 const std::string& command) 113 const std::string& command)
113 { 114 {
114 boost::mutex::scoped_lock lock(mutex_);
115
116 log_.clear(); 115 log_.clear();
117 int error = (luaL_loadbuffer(lua_, command.c_str(), command.size(), "line") || 116 int error = (luaL_loadbuffer(lua_, command.c_str(), command.size(), "line") ||
118 lua_pcall(lua_, 0, 0, 0)); 117 lua_pcall(lua_, 0, 0, 0));
119 118
120 if (error) 119 if (error)
141 } 140 }
142 141
143 142
144 bool LuaContext::IsExistingFunction(const char* name) 143 bool LuaContext::IsExistingFunction(const char* name)
145 { 144 {
146 boost::mutex::scoped_lock lock(mutex_);
147 lua_settop(lua_, 0); 145 lua_settop(lua_, 0);
148 lua_getglobal(lua_, name); 146 lua_getglobal(lua_, name);
149 return lua_type(lua_, -1) == LUA_TFUNCTION; 147 return lua_type(lua_, -1) == LUA_TFUNCTION;
150 } 148 }
151 } 149 }