summaryrefslogtreecommitdiff
path: root/src/thread-pool.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/thread-pool.cpp')
-rw-r--r--src/thread-pool.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/thread-pool.cpp b/src/thread-pool.cpp
index f9ff155..d040fa4 100644
--- a/src/thread-pool.cpp
+++ b/src/thread-pool.cpp
@@ -74,6 +74,9 @@ void inline PkeThreads_Reset_Inner(ThreadPool &tp) {
tp.mutex.lock();
tp.maxJobQueueCount = 0;
tp.completedCount = 0;
+ for (uint32_t i = 0; i < tp.threads.next; ++i) {
+ pk_delete<std::thread>(tp.threads[i]);
+ }
pk_arr_clear(&tp.jobQueue);
pk_arr_clear(&tp.threads);
tp.mutex.unlock();
@@ -208,6 +211,13 @@ void PkeThreads_Teardown(ThreadPoolHandle handle) {
PkeThreads_Shutdown_Inner(*tp);
PkeThreads_JoinAll_Inner(*tp);
PkeThreads_Reset_Inner(*tp);
+
+ for (uint32_t i = 0; i < tp->threads.next; ++i) {
+ if (tp->threads[i] != nullptr) {
+ pk_delete<std::thread>(tp->threads[i]);
+ }
+ }
+
pk_arr_reset(&tp->jobQueue);
pk_arr_reset(&tp->threads);
tp->jobQueue.bkt = CAFE_BABE(struct pk_membucket);