added a vector containing all executed scripts for this session and method to get it.

added a call to sending of scripts via parallel connection as soon as they are executed.
This commit is contained in:
Joakim Kilby
2015-06-23 09:34:34 +02:00
parent b2b7563018
commit fabbd3c1e8
2 changed files with 20 additions and 2 deletions

View File

@@ -78,6 +78,8 @@ public:
void preSynchronization();
void queueScript(const std::string &script);
std::vector<std::string> executedScripts();
std::vector<std::string> allLuaFunctions() const;
@@ -98,6 +100,10 @@ private:
std::vector<std::string> _queuedScripts;
std::vector<std::string> _receivedScripts;
std::string _currentSyncedScript;
//parallel variables @TODO make a more permanent solution to this - JK
std::vector<std::string> _executedScripts;
std::mutex _executedScriptsMutex;
};
} // namespace scripting

View File

@@ -27,7 +27,8 @@
#include <ghoul/logging/logmanager.h>
#include <ghoul/filesystem/filesystem.h>
#include <openspace/util/syncbuffer.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/network/osparallelconnection.h>
#include <ghoul/lua/lua_helper.h>
#include <fstream>
#include <iomanip>
@@ -154,6 +155,8 @@ bool ScriptEngine::runScript(const std::string& script) {
return false;
}
OsEng.parallelConnection()->sendScript(script);
return true;
}
@@ -497,6 +500,10 @@ void ScriptEngine::deserialize(SyncBuffer* syncBuffer){
_mutex.lock();
_receivedScripts.push_back(_currentSyncedScript);
_mutex.unlock();
_executedScriptsMutex.lock();
_executedScripts.push_back(_currentSyncedScript);
_executedScriptsMutex.unlock();
}
}
@@ -527,13 +534,18 @@ void ScriptEngine::preSynchronization(){
void ScriptEngine::queueScript(const std::string &script){
if (script.empty())
return;
_mutex.lock();
_queuedScripts.insert(_queuedScripts.begin(), script);
_mutex.unlock();
}
std::vector<std::string> ScriptEngine::executedScripts(){
std::lock_guard<std::mutex> lockGuard(_executedScriptsMutex);
return _executedScripts;
}
} // namespace scripting