This plugin provides a new node BackgroundWorker
to make it easy to queue up and track background tasks.
This can be used to preload scenes, save games, synchronize or upload files, etc.
All queued up jobs are processed by an adjustable amount of worker threads. For strict linear processing "one after the other" you can reduce the number of active worker threads to one.
Progress is reported back through signals, although hooked up functions can still trigger their own signals from their own thread in case you need it.
The latest version of the addon can be found in my repository.
As with any other Godot addon, put the contents of addons/BackgroundWorker
in your own project's addons
directory and make sure to enable it in Project Setting's "Plugins" tab.
To queue up new jobs, call the member methods queue_job(target, method, [binds])
or queue_load(file, [type_hint]
). Processing starts automatically on the next frame.
The minimum time in seconds the workers have to be busy for visibility to kick in.
The mimium time in seconds the workers have to be idle for visibility to cease
The number of worker threads to be used.
Queues a new job to call method()
on target
passing binds
(if set).
Queues loading a file using Godot's load()
, passing the optional type_hint
(if set).
Remove/cancel any queued job not yet started.
Return the number of queued jobs not yet started.
Triggered as soon as the first job starts processing.
Triggered once all queued up jobs have finished processing.
Triggered once busy longer than defined in show_timeout
to show a visible indicator.
Triggered once all queued up jobs have finished and the timeout defined in hide_timeout
has passed to hide indicators.
Triggered whenever progress is made. This can be used to show relative progress to the user.