Brian Huynh 2024-11-16 08:54:20 -05:00 committed by GitHub
parent 5efd124ca1
commit a23a0c2493
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -6,6 +6,7 @@
<description>
The [WorkerThreadPool] singleton allocates a set of [Thread]s (called worker threads) on project startup and provides methods for offloading tasks to them. This can be used for simple multithreading without having to create [Thread]s.
Tasks hold the [Callable] to be run by the threads. [WorkerThreadPool] can be used to create regular tasks, which will be taken by one worker thread, or group tasks, which can be distributed between multiple worker threads. Group tasks execute the [Callable] multiple times, which makes them useful for iterating over a lot of elements, such as the enemies in an arena.
[b]Note:[/b] The amount of threads created is given by the [OS] as the amount of processors on the system-1 unless it is on a browser in which case it will be 0
Here's a sample on how to offload an expensive function to worker threads:
[codeblocks]
[gdscript]