summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2021-11-02 01:51:43 +0100
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2021-11-02 04:16:00 +0100
commit4ed1d977fcca5922cf8254b1ffbf16cf47b310b4 (patch)
tree39492aaf8f883eadc8230dfcacd22d7e05c45027 /platform
parent455e027725668742a52e08a173ea337a3c416b25 (diff)
[OS] Add ThreadWorkPool default size to OS.
Some platforms (*cough* web *cough*) have hard limits on the number of threads that can be spawned. Currently, ThreadPoolWork (mostly used in rendering/physics servers) will spawn as many threads as CPUs available causing exception on machines with high CPU count. This commit adds a new overridable method to OS that returns the default thread pool size (still the CPU count by default), and overrides it for the JavaScript platform so it always allocate only one thread. We can likely improve the whole ThreadPoolWork in the future to always allocate X amount of threads, and assign jobs to them on the fly, but that will require some more architectural changes.
Diffstat (limited to 'platform')
-rw-r--r--platform/javascript/os_javascript.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h
index d053082d92..aacf87e6c5 100644
--- a/platform/javascript/os_javascript.h
+++ b/platform/javascript/os_javascript.h
@@ -75,6 +75,7 @@ public:
Error kill(const ProcessID &p_pid) override;
int get_process_id() const override;
int get_processor_count() const override;
+ int get_default_thread_pool_size() const override { return 1; }
String get_executable_path() const override;
Error shell_open(String p_uri) override;