summaryrefslogtreecommitdiffstats
path: root/core/os
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-01-11 17:38:09 +0100
committerRémi Verschelde <rverschelde@gmail.com>2024-01-11 17:38:09 +0100
commitdc79e956b628bb71a3ecbfdab6edd19ce6cf918f (patch)
treed1770397e511ed3f230e03d983bc4c3c7cb1e36c /core/os
parent9e967ebdf90e32fb93a7895a19a4111e72d9c660 (diff)
parenta7317748135e064ff150072f2f46ccc1d2c4b358 (diff)
downloadredot-engine-dc79e956b628bb71a3ecbfdab6edd19ce6cf918f.tar.gz
Merge pull request #86587 from RandomShaper/wtp_enhance
Enhance & fix `WorkerThreadPool`
Diffstat (limited to 'core/os')
-rw-r--r--core/os/condition_variable.h2
-rw-r--r--core/os/semaphore.h8
2 files changed, 7 insertions, 3 deletions
diff --git a/core/os/condition_variable.h b/core/os/condition_variable.h
index 6a6996019d..6a49ced31b 100644
--- a/core/os/condition_variable.h
+++ b/core/os/condition_variable.h
@@ -31,6 +31,8 @@
#ifndef CONDITION_VARIABLE_H
#define CONDITION_VARIABLE_H
+#include "core/os/mutex.h"
+
#ifdef MINGW_ENABLED
#define MINGW_STDTHREAD_REDUNDANCY_WARNING
#include "thirdparty/mingw-std-threads/mingw.condition_variable.h"
diff --git a/core/os/semaphore.h b/core/os/semaphore.h
index 8bb1529bbd..b8ae35b86b 100644
--- a/core/os/semaphore.h
+++ b/core/os/semaphore.h
@@ -58,10 +58,12 @@ private:
#endif
public:
- _ALWAYS_INLINE_ void post() const {
+ _ALWAYS_INLINE_ void post(uint32_t p_count = 1) const {
std::lock_guard lock(mutex);
- count++;
- condition.notify_one();
+ count += p_count;
+ for (uint32_t i = 0; i < p_count; ++i) {
+ condition.notify_one();
+ }
}
_ALWAYS_INLINE_ void wait() const {