Skip to content

Use dedicated threadpool for Godot threads

Rafał Mikrut requested to merge github/fork/dragmz/threadpool into master

Created by: dragmz

Follow up to #25213 which I didn't mean to close.

--

Alternative fix to #25117

Although the concept is the same (i.e. use a thread pool) this implementation uses a dedicated thread pool rather than the default one.

This is better than using QueueUserWorkItem because the dedicated thread pool can be set with a minimum number of threads that are pre-allocated to handle the queue work items.

The minimum number of threads is configured with "thread_pool/min" project setting. By default it's 0 (so for the first work item it works the same as CreateThread) but can be changed to a higher number for projects that use threads extensively.

Please note that this uses Windows Vista+ API however that shoulld be fine as Godot already seems to require Vista+ (I didn't know about it when implmenting #25117 and that's the reason why I'm proposing this alternative now).

Merge request reports