|
Legofit
infers population history from nucleotide site patterns.
|
Multithreaded job queue. More...
#include "jobqueue.h"#include "misc.h"#include <stdlib.h>#include <string.h>#include <assert.h>#include <pthread.h>#include <stdbool.h>#include <time.h>#include "dprintf.h"Data Structures | |
| struct | Job |
| A single job in the queue. More... | |
| struct | JobQueue |
| All data used by job queue. More... | |
Macros | |
| #define | ERR(code, msg) |
| #define | CHECKMEM(x) |
| #define | JOBQUEUE_VALID 8131950 |
Functions | |
| void * | threadfun (void *arg) |
| Waits until there is a job in the queue, pops it off and executes it, then waits for another. | |
| void | Job_free (Job *job) |
| Destroy a Job. | |
| JobQueue * | JobQueue_new (int maxThreads, void *threadData, void *(*ThreadState_new)(void *), void(*ThreadState_free)(void *)) |
| Construct a JobQueue. | |
| void | JobQueue_addJob (JobQueue *jq, int(*jobfun)(void *, void *), void *param) |
| Add a job to the queue. | |
| void | JobQueue_noMoreJobs (JobQueue *jq) |
| Stop accepting jobs. | |
| void | JobQueue_waitOnJobs (JobQueue *jq) |
| Wait until all threads are idle. | |
| void | JobQueue_free (JobQueue *jq) |
| Destroy a JobQueue. | |
Multithreaded job queue.
This file implements a multithreaded job queue. Jobs are pushed onto a queue by the main program. Each thread (or worker) removes a job from the queue, executes it, and then goes back for another. When all jobs are finished, control returns to the main function.
| #define CHECKMEM | ( | x | ) |
| #define ERR | ( | code, | |
| msg ) |
| void JobQueue_addJob | ( | JobQueue * | jq, |
| int(* | jobfun )(void *, void *), | ||
| void * | param ) |
Add a job to the queue.
| jq | the JobQueue |
| jobfun | function to be executed. Takes two void* arguments. The first points to a structure containing data associated with this job. The second points to data associated with the thread that runs the job. For example, the 2nd argument can be used to maintain a separate random number generator within each thread. |
| param | pointer to structure with parameters for this job |
References threadfun().
Referenced by diffev().
| void * threadfun | ( | void * | arg | ) |
Waits until there is a job in the queue, pops it off and executes it, then waits for another.
Runs until jobs are completed and main thread sets acceptingJobs=0.
Referenced by JobQueue_addJob().