Mercurial > hg > orthanc
diff OrthancServer/LuaScripting.h @ 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 | f7a84b551ee4 |
children | 912a767911b0 |
line wrap: on
line diff
--- a/OrthancServer/LuaScripting.h Mon May 21 09:00:20 2018 +0200 +++ b/OrthancServer/LuaScripting.h Tue May 22 12:25:37 2018 +0200 @@ -37,6 +37,7 @@ #include "ServerJobs/LuaJobManager.h" +#include "../Core/MultiThreading/SharedMessageQueue.h" #include "../Core/Lua/LuaContext.h" namespace Orthanc @@ -46,6 +47,11 @@ class LuaScripting : public IServerListener { private: + class ExecuteEvent; + class IEvent; + class OnStoredInstanceEvent; + class StableResourceEvent; + static ServerContext* GetServerContext(lua_State *state); static int RestApiPostOrPut(lua_State *state, @@ -56,35 +62,33 @@ static int RestApiDelete(lua_State *state); static int GetOrthancConfiguration(lua_State *state); - void ApplyOnStoredInstance(const std::string& instanceId, - const Json::Value& simplifiedDicom, - const Json::Value& metadata, - const DicomInstanceToStore& instance); - size_t ParseOperation(LuaJobManager::Lock& lock, const std::string& operation, const Json::Value& parameters); void InitializeJob(); - void SubmitJob(const std::string& description); - - void OnStableResource(const ServerIndexChange& change); + void SubmitJob(); - boost::recursive_mutex mutex_; - LuaContext lua_; - ServerContext& context_; - LuaJobManager jobManager_; + boost::mutex mutex_; + LuaContext lua_; + ServerContext& context_; + LuaJobManager jobManager_; + bool continue_; + boost::thread eventThread_; + SharedMessageQueue pendingEvents_; + + static void EventThread(LuaScripting* that); public: - class Locker : public boost::noncopyable + class Lock : public boost::noncopyable { private: - LuaScripting& that_; - boost::recursive_mutex::scoped_lock lock_; + LuaScripting& that_; + boost::mutex::scoped_lock lock_; public: - Locker(LuaScripting& that) : + Lock(LuaScripting& that) : that_(that), lock_(that.mutex_) { @@ -97,6 +101,12 @@ }; LuaScripting(ServerContext& context); + + ~LuaScripting(); + + void Start(); + + void Stop(); virtual void SignalStoredInstance(const std::string& publicId, DicomInstanceToStore& instance, @@ -108,5 +118,7 @@ const Json::Value& simplifiedTags); void Execute(const std::string& command); + + void LoadGlobalConfiguration(); }; }