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.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/thread_pool.cpp b/src/thread_pool.cpp
index 0fc9880..e2ef3cd 100644
--- a/src/thread_pool.cpp
+++ b/src/thread_pool.cpp
@@ -15,10 +15,10 @@ struct ThreadPool {
std::condition_variable condition;
DynArray<std::packaged_task<void()> *> *jobQueue;
DynArray<std::thread> *threads;
- MemBucket *bkt = nullptr;
+ struct pk_membucket *bkt = nullptr;
};
-const PkeHandleItemIndex_T MAX_THREADS_PER_BUCKET = 8;
+const pk_handle_item_index_T MAX_THREADS_PER_BUCKET = 8;
BucketContainer<ThreadPool, ThreadPoolHandle> ThreadPool_BucketContainer{};
@@ -45,7 +45,7 @@ void ThreadRun(ThreadPool *tp) {
}
assert(j != nullptr);
(*j)();
- Pke_Delete<std::packaged_task<void()>>(j, tp->bkt);
+ pk_delete<std::packaged_task<void()>>(j, tp->bkt);
tp->completedCount = tp->completedCount + 1;
}
}
@@ -128,7 +128,7 @@ void PkeThreads_Init() {
Buckets_Init(ThreadPool_BucketContainer, MAX_THREADS_PER_BUCKET);
}
-ThreadPoolHandle PkeThreads_Init(uint8_t threadCount, uint8_t maxQueueCount, MemBucket *bkt) {
+ThreadPoolHandle PkeThreads_Init(uint8_t threadCount, uint8_t maxQueueCount, struct pk_membucket *bkt) {
assert(threadCount > 0);
ThreadPoolHandle newHandle{Buckets_NewHandle(ThreadPool_BucketContainer)};
@@ -139,8 +139,8 @@ ThreadPoolHandle PkeThreads_Init(uint8_t threadCount, uint8_t maxQueueCount, Mem
tp->isPaused = false;
tp->maxJobQueueCount = maxQueueCount;
tp->completedCount = 0;
- tp->jobQueue = Pke_New<DynArray<std::packaged_task<void()> *>>(bkt);
- tp->threads = Pke_New<DynArray<std::thread>>(bkt);
+ tp->jobQueue = pk_new<DynArray<std::packaged_task<void()> *>>(bkt);
+ tp->threads = pk_new<DynArray<std::thread>>(bkt);
tp->threads->Resize(threadCount);
for (long l = 0; l < threadCount; ++l) {
@@ -162,10 +162,10 @@ bool PkeThreads_Enqueue(ThreadPoolHandle handle, std::packaged_task<void()> *job
if (tp->bkt != nullptr) {
/* 2023-12-22 JCB
* Note that if this becomes an issue we can change it.
- * Technically speaking, if we call the right Pke_Delete
- * we don't even need to worry about passing the MemBucket
+ * Technically speaking, if we call the right pk_delete
+ * we don't even need to worry about passing the struct pk_membucket
*/
- assert(Pke_InBucket(job, tp->bkt) == true && "cannot enqueue packaged task from a non-matching MemBucket");
+ assert(pk_memory_is_in_bucket(job, tp->bkt) == true && "cannot enqueue packaged task from a non-matching struct pk_membucket");
}
return PkeThreads_Enqueue_Inner(*tp, job);
@@ -205,11 +205,11 @@ void PkeThreads_Teardown(ThreadPoolHandle handle) {
PkeThreads_Shutdown_Inner(*tp);
PkeThreads_JoinAll_Inner(*tp);
PkeThreads_Reset_Inner(*tp);
- Pke_Delete<DynArray<std::packaged_task<void()> *>>(tp->jobQueue, tp->bkt);
- Pke_Delete<DynArray<std::thread>>(tp->threads, tp->bkt);
+ pk_delete<DynArray<std::packaged_task<void()> *>>(tp->jobQueue, tp->bkt);
+ pk_delete<DynArray<std::thread>>(tp->threads, tp->bkt);
tp->jobQueue = CAFE_BABE(DynArray<std::packaged_task<void()> *>);
tp->threads = CAFE_BABE(DynArray<std::thread>);
- tp->bkt = CAFE_BABE(MemBucket);
+ tp->bkt = CAFE_BABE(struct pk_membucket);
}
void PkeThreads_Teardown() {