1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-05 19:31:04 +00:00

Add API to cancel async jobs (#14602)

* Implement API to cancel async jobs

Co-authored-by: sfan5 <sfan5@live.de>

* update AsyncJob:cancel documentation from review

* Use IPC to unblock async

* review

* review async unblocking

* review

* Apply suggestions from code review

Co-authored-by: sfan5 <sfan5@live.de>

* minor licensing

---------

Co-authored-by: y5nw <y5nw@protonmail.com>
Co-authored-by: sfan5 <sfan5@live.de>
This commit is contained in:
y5nw 2025-08-26 12:40:31 +02:00 committed by GitHub
parent 7cbe62fe7b
commit f390137d6e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 229 additions and 78 deletions

View file

@ -22,6 +22,7 @@ struct PackedValue;
class ServerScripting:
virtual public ScriptApiBase,
public ScriptApiAsync,
public ScriptApiDetached,
public ScriptApiEntity,
public ScriptApiEnv,
@ -41,14 +42,7 @@ public:
void saveGlobals();
// Initialize async engine, call this AFTER loading all mods
void initAsync();
// Global step handler to collect async results
void stepAsync();
// Pass job to async threads
u32 queueAsync(std::string &&serialized_func,
PackedValue *param, const std::string &mod_origin);
void initAsync() override;
protected:
// from ScriptApiSecurity:
@ -63,6 +57,4 @@ private:
void InitializeModApi(lua_State *L, int top);
static void InitializeAsync(lua_State *L, int top);
AsyncEngine asyncEngine;
};