Skip to content

Commit

Permalink
Merge pull request Pithikos#41 from bowfin/return-void-extern-C
Browse files Browse the repository at this point in the history
Change worker return type to void; add extern C
  • Loading branch information
Pithikos authored Sep 4, 2016
2 parents dacf776 + 5255277 commit ea938fc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
8 changes: 4 additions & 4 deletions thpool.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ typedef struct bsem {
/* Job */
typedef struct job{
struct job* prev; /* pointer to previous job */
void* (*function)(void* arg); /* function pointer */
void (*function)(void* arg); /* function pointer */
void* arg; /* function's argument */
} job;

Expand Down Expand Up @@ -165,7 +165,7 @@ struct thpool_* thpool_init(int num_threads){


/* Add work to the thread pool */
int thpool_add_work(thpool_* thpool_p, void *(*function_p)(void*), void* arg_p){
int thpool_add_work(thpool_* thpool_p, void (*function_p)(void*), void* arg_p){
job* newjob;

newjob=(struct job*)malloc(sizeof(struct job));
Expand Down Expand Up @@ -342,8 +342,8 @@ static void* thread_do(struct thread* thread_p){
pthread_mutex_unlock(&thpool_p->thcount_lock);

/* Read job from queue and execute it */
void*(*func_buff)(void* arg);
void* arg_buff;
void (*func_buff)(void* arg);
void* arg_buff;
job* job_p;
pthread_mutex_lock(&thpool_p->jobqueue_p->rwmutex);
job_p = jobqueue_pull(thpool_p);
Expand Down
13 changes: 7 additions & 6 deletions thpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
#ifndef _THPOOL_
#define _THPOOL_




#ifdef __cplusplus
extern "C" {
#endif

/* =================================== API ======================================= */

Expand Down Expand Up @@ -64,7 +64,7 @@ threadpool thpool_init(int num_threads);
* @param arg_p pointer to an argument
* @return 0 on successs, -1 otherwise.
*/
int thpool_add_work(threadpool, void *(*function_p)(void*), void* arg_p);
int thpool_add_work(threadpool, void (*function_p)(void*), void* arg_p);


/**
Expand Down Expand Up @@ -158,7 +158,8 @@ void thpool_resume(threadpool);
*/
void thpool_destroy(threadpool);



#ifdef __cplusplus
}
#endif

#endif

0 comments on commit ea938fc

Please sign in to comment.