Skip to content

Commit

Permalink
🎨 threadpool
Browse files Browse the repository at this point in the history
  • Loading branch information
fennecdjay committed Feb 17, 2024
1 parent ee0fbca commit b2b8760
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions include/threadpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ ANN static inline int gwt_signal(gwtcond_t *cond) {
}
ANN static inline int gwt_create(gwtthread_t *thread, gwtreturn_t (*fun)(void*), void *arg) {
*thread = CreateThread(NULL, 0, fun, arg, 0, NULL);
return 0;
return !!*thread;
}
ANN static inline void gwt_join(gwtthread_t thread) {
WaitForSingleObject(thread, INFINITE); // dword // (DWORD)0xFFFFFFFF on error
Expand Down Expand Up @@ -102,7 +102,7 @@ ANN static inline void gwt_cond_end(gwtcond_t *cond) {
pthread_cond_destroy(cond); // int
}
ANN static inline bool gwt_create(gwtthread_t *thread, gwtreturn_t (*fun)(void*), void *arg) {
return !pthread_create(thread, NULL, fun, arg); // int
return pthread_create(thread, NULL, fun, arg); // int
}
#endif

Expand Down
5 changes: 2 additions & 3 deletions src/threadpool.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ ANN static bool utils(threadpool_t *p) {

ANN static bool start(threadpool_t *p, const uint32_t thread_count) {
for(uint32_t i = 0; i < thread_count; i++) {
if(!gwt_create(&p->threads[i], threadpool_thread, p))
return false;
const int ret = gwt_create(&p->threads[i], threadpool_thread, p);
if(ret) return false;
p->started++;
}
return true;
Expand All @@ -75,7 +75,6 @@ threadpool_t *new_threadpool(const uint32_t thread_count, const uint32_t queue_s
free_threadpool(p);
return NULL;
}

return p;
}

Expand Down

0 comments on commit b2b8760

Please sign in to comment.