Source/Backend/thread_pool/gtr_thread_pool.c
static job *job_queue_pull(job_queue *job_queue_p) {

    pthread_mutex_lock(&job_queue_p->rwmutex);
    job *job_p = job_queue_p->front;

    switch (job_queue_p->length) {

        case 0:  /* if no jobs in queue */
            break;

        case 1:  /* if one job in queue */
            job_queue_p->front = NULL;
            job_queue_p->rear = NULL;
            job_queue_p->length = 0;
            break;

        default: /* if >1 jobs in queue */
            job_queue_p->front = job_p->prev;
            job_queue_p->length--;
            /* more than one job in queue -> post it */
            binary_semaphore_post(job_queue_p->has_jobs);

    }

    pthread_mutex_unlock(&job_queue_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
Get first job from queue ( removes it from queue ) Notice : Caller MUST hold a mutex
static job *job_queue_pull(job_queue *job_queue_p) {
    pthread_mutex_lock(&job_queue_p->rwmutex);
    job *job_p = job_queue_p->front;
    switch (job_queue_p->length) {
        case 0:  
            break;
        case 1:  
            job_queue_p->front = NULL;
            job_queue_p->rear = NULL;
            job_queue_p->length = 0;
            break;
        default: 
            job_queue_p->front = job_p->prev;
            job_queue_p->length--;
            binary_semaphore_post(job_queue_p->has_jobs);
    }
    pthread_mutex_unlock(&job_queue_p->rwmutex);
    return job_p;
}
static job * job_queue_pull ( job_queue * job_queue_p ) { pthread_mutex_lock ( & job_queue_p -> rwmutex ) ; job * job_p = job_queue_p -> front ; switch ( job_queue_p -> length ) { case 0 : break ; case 1 : job_queue_p -> front = NULL ; job_queue_p -> rear = NULL ; job_queue_p -> length = 0 ; break ; default : job_queue_p -> front = job_p -> prev ; job_queue_p -> length -- ; binary_semaphore_post ( job_queue_p -> has_jobs ) ; } pthread_mutex_unlock ( & job_queue_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 */