MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / jobqueue_pull

Function jobqueue_pull

src/util/thpool/thpool.c:518–543  ·  view source on GitHub ↗

Get first job from queue(removes it from queue) * * Notice: Caller MUST hold a mutex */

Source from the content-addressed store, hash-verified

516 * Notice: Caller MUST hold a mutex
517 */
518static struct job *jobqueue_pull(jobqueue *jobqueue_p) {
519
520 pthread_mutex_lock(&jobqueue_p->rwmutex);
521 job *job_p = jobqueue_p->front;
522
523 switch(jobqueue_p->len) {
524
525 case 0: /* if no jobs in queue */
526 break;
527
528 case 1: /* if one job in queue */
529 jobqueue_p->front = NULL;
530 jobqueue_p->rear = NULL;
531 jobqueue_p->len = 0;
532 break;
533
534 default: /* if >1 jobs in queue */
535 jobqueue_p->front = job_p->prev;
536 jobqueue_p->len--;
537 /* more than one job in queue -> post it */
538 bsem_post(jobqueue_p->has_jobs);
539 }
540
541 pthread_mutex_unlock(&jobqueue_p->rwmutex);
542 return job_p;
543}
544
545/* Free all queue resources back to the system */
546static void jobqueue_destroy(jobqueue *jobqueue_p) {

Callers 2

thread_doFunction · 0.85
jobqueue_clearFunction · 0.85

Calls 1

bsem_postFunction · 0.85

Tested by

no test coverage detected