server/thpool.c
/* Get first job from queue(removes it from queue)
 *
 * Notice: Caller MUST hold a mutex
 */
Get first job from queue(removes it from queue)
Notice: Caller MUST hold a mutex
Get first job from queue ( removes it from queue ) Notice : Caller MUST hold a mutex
static struct job *jobqueue_pull(jobqueue *jobqueue_p) {
    pthread_mutex_lock(&jobqueue_p->rwmutex);
    job *job_p = jobqueue_p->front;
    switch (jobqueue_p->len) {
        case 0:  
            break;
        case 1:  
            jobqueue_p->front = NULL;
            jobqueue_p->rear = NULL;
            jobqueue_p->len = 0;
            break;
        default: 
            jobqueue_p->front = job_p->prev;
            jobqueue_p->len--;
            bsem_post(jobqueue_p->has_jobs);
    }
    pthread_mutex_unlock(&jobqueue_p->rwmutex);
    return job_p;
}
static struct job * jobqueue_pull ( jobqueue * jobqueue_p ) { pthread_mutex_lock ( & jobqueue_p -> rwmutex ) ; job * job_p = jobqueue_p -> front ; switch ( jobqueue_p -> len ) { case 0 : break ; case 1 : jobqueue_p -> front = NULL ; jobqueue_p -> rear = NULL ; jobqueue_p -> len = 0 ; break ; default : jobqueue_p -> front = job_p -> prev ; jobqueue_p -> len -- ; bsem_post ( jobqueue_p -> has_jobs ) ; } pthread_mutex_unlock ( & jobqueue_p -> rwmutex ) ; return job_p ; }
Get first job from queue(removes it from queue)
 Notice: Caller MUST hold a mutex
Get first job from queue ( removes it from queue ) Notice : Caller MUST hold a mutex
/* if no jobs in queue */ /* if one job in queue */ /* if >1 jobs in queue */ /* more than one job in queue -> post it */