Mercurial > hg > orthanc
diff OrthancServer/OrthancFindRequestHandler.cpp @ 2616:2f3007bf0708 jobs
event queues in Lua, serialization of sequence of operations
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 22 May 2018 12:25:37 +0200 |
parents | 6f9225dcfc32 |
children | 912a767911b0 |
line wrap: on
line diff
--- a/OrthancServer/OrthancFindRequestHandler.cpp Mon May 21 09:00:20 2018 +0200 +++ b/OrthancServer/OrthancFindRequestHandler.cpp Tue May 22 12:25:37 2018 +0200 @@ -47,6 +47,25 @@ namespace Orthanc { + static LuaScripting& GetLuaScripting(ServerContext& context) + { + // Returns a singleton Lua context + static boost::mutex mutex_; + static std::auto_ptr<LuaScripting> lua_; + + boost::mutex::scoped_lock lock(mutex_); + + if (lua_.get() == NULL) + { + LOG(INFO) << "Initializing Lua for OrthancFindRequestHandler"; + lua_.reset(new LuaScripting(context)); + lua_->LoadGlobalConfiguration(); + } + + return *lua_; + } + + static void GetChildren(std::list<std::string>& target, ServerIndex& index, const std::list<std::string>& source) @@ -485,9 +504,9 @@ const std::string& calledAet) { static const char* LUA_CALLBACK = "IncomingFindRequestFilter"; - - LuaScripting::Locker locker(context_.GetLuaScripting()); - if (!locker.GetLua().IsExistingFunction(LUA_CALLBACK)) + + LuaScripting::Lock lock(GetLuaScripting(context_)); + if (!lock.GetLua().IsExistingFunction(LUA_CALLBACK)) { return false; } @@ -498,7 +517,7 @@ origin["RemoteAet"] = remoteAet; origin["CalledAet"] = calledAet; - LuaFunctionCall call(locker.GetLua(), LUA_CALLBACK); + LuaFunctionCall call(lock.GetLua(), LUA_CALLBACK); call.PushDicom(source); call.PushJson(origin); FromDcmtkBridge::ExecuteToDicom(target, call); @@ -508,6 +527,14 @@ } + OrthancFindRequestHandler::OrthancFindRequestHandler(ServerContext& context) : + context_(context), + maxResults_(0), + maxInstances_(0) + { + } + + void OrthancFindRequestHandler::Handle(DicomFindAnswers& answers, const DicomMap& input, const std::list<DicomTag>& sequencesToReturn,