#ifndef GS2SCRIPTMANAGER_H #define GS2SCRIPTMANAGER_H #include #include #include #include #include #include "scripting/interface/ScriptUtils.h" class GS2ScriptManager { using BytecodeCache = std::unordered_map; // used for threadpool job queue using CompilerThreadPool = CustomThreadPool; using internal_callback_type = std::function; using queue_item_type = std::pair; public: using user_callback_type = std::function; GS2ScriptManager(); ~GS2ScriptManager() {} void compileScript(const std::string& script, user_callback_type finishedCb); void runQueue(); private: // Async Compile void queueCompileJob(const std::string& script, user_callback_type& finishedCb); // Sync Compile GS2Context _context; void syncCompileJob(const std::string& script, user_callback_type& finishedCb); BytecodeCache m_bytecodeCache; CompilerThreadPool m_compilerThreadPool; std::queue m_cbQueue; std::mutex m_cbQueueLock; }; #endif