24#include <unordered_set>
106 const std::string &mod_origin =
"");
115 const std::string &mod_origin =
"");
121 void step(lua_State *L);
unsigned int autoscaleMaxWorkers
Definition: s_async.h:169
~AsyncEngine()
Definition: s_async.cpp:39
std::unordered_set< u32 > autoscaleSeenJobs
Definition: s_async.h:171
u32 queueAsyncJob(std::string &&func, std::string &¶ms, const std::string &mod_origin="")
Queue an async job.
Definition: s_async.cpp:104
u64 autoscaleTimer
Definition: s_async.h:170
std::vector< AsyncWorkerThread * > workerThreads
Definition: s_async.h:193
std::deque< LuaJobInfo > jobQueue
Definition: s_async.h:185
void stepJobResults(lua_State *L)
Process finished jobs callbacks.
Definition: s_async.cpp:171
Semaphore jobQueueCounter
Definition: s_async.h:196
std::deque< LuaJobInfo > resultQueue
Definition: s_async.h:190
AsyncEngine(Server *server)
Definition: s_async.h:84
void registerStateInitializer(StateInitializer func)
Register function to be called on new states.
Definition: s_async.cpp:69
void putJobResult(LuaJobInfo &&result)
Put a Job result back to result queue.
Definition: s_async.cpp:157
void stepAutoscale()
Handle automatic scaling of worker threads.
Definition: s_async.cpp:205
bool prepareEnvironment(lua_State *L, int top)
Initialize environment with current registred functions this function adds all functions registred by...
Definition: s_async.cpp:240
bool getJob(LuaJobInfo *job)
Get a Job from queue to be processed this function blocks until a job is ready.
Definition: s_async.cpp:139
void step(lua_State *L)
Engine step to process finished jobs.
Definition: s_async.cpp:165
void(* StateInitializer)(lua_State *L, int top)
Definition: s_async.h:81
std::vector< StateInitializer > stateInitializers
Definition: s_async.h:177
u32 jobIdCounter
Definition: s_async.h:180
void initialize(unsigned int numEngines)
Create async engine tasks and lock function registration.
Definition: s_async.cpp:76
std::mutex jobQueueMutex
Definition: s_async.h:183
bool initDone
Definition: s_async.h:165
void addWorkerThread()
Start an additional worker thread.
Definition: s_async.cpp:95
std::mutex resultQueueMutex
Definition: s_async.h:188
bool isErrored
Definition: s_async.h:75
virtual ~AsyncWorkerThread()
Definition: s_async.cpp:305
void * run()
Definition: s_async.cpp:311
AsyncEngine * jobDispatcher
Definition: s_async.h:74
Definition: s_security.h:41
Definition: semaphore.h:33
static LightingParams params
Definition: light.cpp:40
Definition: activeobjectmgr.cpp:26
std::unique_ptr< PackedValue > params_ext
Definition: s_async.h:50
std::string mod_origin
Definition: s_async.h:56
std::string function
Definition: s_async.h:46
std::string result
Definition: s_async.h:52
std::string params
Definition: s_async.h:48
std::unique_ptr< PackedValue > result_ext
Definition: s_async.h:54
u32 id
Definition: s_async.h:58
A packed value can be a primitive like a string or number but also a table including all of its conte...
Definition: c_packer.h:87