1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-09-05 18:41:05 +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

@ -7210,12 +7210,12 @@ This allows you easy interoperability for delegating work to jobs.
* When `func` returns the callback is called (in the normal environment)
with all of the return values as arguments.
* Optional: Variable number of arguments that are passed to `func`
* Returns an `AsyncJob` async job.
* `core.register_async_dofile(path)`:
* Register a path to a Lua file to be imported when an async environment
is initialized. You can use this to preload code which you can then call
later using `core.handle_async()`.
### List of APIs available in an async environment
Classes:
@ -8050,6 +8050,15 @@ use the provided load and write functions for this.
* `from_file(filename)`: Experimental. Like `from_string()`, but reads the data
from a file.
`AsyncJob`
----------
An `AsyncJob` is a reference to a job to be run in an async environment.
### Methods
* `cancel()`: try to cancel the job
* Returns whether the job was cancelled.
* A job can only be cancelled if it has not started.
`InvRef`
--------