src/dird/jobq.c
int jobq_init(jobq_t *jq, int threads, void *(*engine)(void *arg))
{
   int stat;
   jobq_item_t *item = NULL;

   if ((stat = pthread_attr_init(&jq->attr)) != 0) {
      berrno be;
      Jmsg1(NULL, M_ERROR, 0, _("pthread_attr_init: ERR=%s\n"), be.bstrerror(stat));
      return stat;
   }
   if ((stat = pthread_attr_setdetachstate(&jq->attr, PTHREAD_CREATE_DETACHED)) != 0) {
      pthread_attr_destroy(&jq->attr);
      return stat;
   }
   if ((stat = pthread_mutex_init(&jq->mutex, NULL)) != 0) {
      berrno be;
      Jmsg1(NULL, M_ERROR, 0, _("pthread_mutex_init: ERR=%s\n"), be.bstrerror(stat));
      pthread_attr_destroy(&jq->attr);
      return stat;
   }
   if ((stat = pthread_cond_init(&jq->work, NULL)) != 0) {
      berrno be;
      Jmsg1(NULL, M_ERROR, 0, _("pthread_cond_init: ERR=%s\n"), be.bstrerror(stat));
      pthread_mutex_destroy(&jq->mutex);
      pthread_attr_destroy(&jq->attr);
      return stat;
   }
   jq->quit = false;
   jq->max_workers = threads;         /* max threads to create */
   jq->num_workers = 0;               /* no threads yet */
   jq->idle_workers = 0;              /* no idle threads */
   jq->engine = engine;               /* routine to run */
   jq->valid = JOBQ_VALID;
   /* Initialize the job queues */
   jq->waiting_jobs = New(dlist(item, &item->link));
   jq->running_jobs = New(dlist(item, &item->link));
   jq->ready_jobs = New(dlist(item, &item->link));
   return 0;
}
/*
 * Initialize a job queue
 *
 *  Returns: 0 on success
 *           errno on failure
 */
Initialize a job queue
Returns: 0 on success
errno on failure
Initialize a job queue Returns : 0 on success errno on failure
int jobq_init(jobq_t *jq, int threads, void *(*engine)(void *arg))
{
   int stat;
   jobq_item_t *item = NULL;
   if ((stat = pthread_attr_init(&jq->attr)) != 0) {
      berrno be;
      Jmsg1(NULL, M_ERROR, 0, _("pthread_attr_init: ERR=%s\n"), be.bstrerror(stat));
      return stat;
   }
   if ((stat = pthread_attr_setdetachstate(&jq->attr, PTHREAD_CREATE_DETACHED)) != 0) {
      pthread_attr_destroy(&jq->attr);
      return stat;
   }
   if ((stat = pthread_mutex_init(&jq->mutex, NULL)) != 0) {
      berrno be;
      Jmsg1(NULL, M_ERROR, 0, _("pthread_mutex_init: ERR=%s\n"), be.bstrerror(stat));
      pthread_attr_destroy(&jq->attr);
      return stat;
   }
   if ((stat = pthread_cond_init(&jq->work, NULL)) != 0) {
      berrno be;
      Jmsg1(NULL, M_ERROR, 0, _("pthread_cond_init: ERR=%s\n"), be.bstrerror(stat));
      pthread_mutex_destroy(&jq->mutex);
      pthread_attr_destroy(&jq->attr);
      return stat;
   }
   jq->quit = false;
   jq->max_workers = threads;         
   jq->num_workers = 0;               
   jq->idle_workers = 0;              
   jq->engine = engine;               
   jq->valid = JOBQ_VALID;
   jq->waiting_jobs = New(dlist(item, &item->link));
   jq->running_jobs = New(dlist(item, &item->link));
   jq->ready_jobs = New(dlist(item, &item->link));
   return 0;
}
int jobq_init ( jobq_t * jq , int threads , void * ( * engine ) ( void * arg ) ) { int stat ; jobq_item_t * item = NULL ; if ( ( stat = pthread_attr_init ( & jq -> attr ) ) != 0 ) { berrno be ; Jmsg1 ( NULL , M_ERROR , 0 , _ ( " \n " ) , be . bstrerror ( stat ) ) ; return stat ; } if ( ( stat = pthread_attr_setdetachstate ( & jq -> attr , PTHREAD_CREATE_DETACHED ) ) != 0 ) { pthread_attr_destroy ( & jq -> attr ) ; return stat ; } if ( ( stat = pthread_mutex_init ( & jq -> mutex , NULL ) ) != 0 ) { berrno be ; Jmsg1 ( NULL , M_ERROR , 0 , _ ( " \n " ) , be . bstrerror ( stat ) ) ; pthread_attr_destroy ( & jq -> attr ) ; return stat ; } if ( ( stat = pthread_cond_init ( & jq -> work , NULL ) ) != 0 ) { berrno be ; Jmsg1 ( NULL , M_ERROR , 0 , _ ( " \n " ) , be . bstrerror ( stat ) ) ; pthread_mutex_destroy ( & jq -> mutex ) ; pthread_attr_destroy ( & jq -> attr ) ; return stat ; } jq -> quit = false ; jq -> max_workers = threads ; jq -> num_workers = 0 ; jq -> idle_workers = 0 ; jq -> engine = engine ; jq -> valid = JOBQ_VALID ; jq -> waiting_jobs = New ( dlist ( item , & item -> link ) ) ; jq -> running_jobs = New ( dlist ( item , & item -> link ) ) ; jq -> ready_jobs = New ( dlist ( item , & item -> link ) ) ; return 0 ; }
Initialize a job queue
  Returns: 0 on success
           errno on failure
Initialize a job queue Returns : 0 on success errno on failure
/* max threads to create */ /* no threads yet */ /* no idle threads */ /* routine to run */ /* Initialize the job queues */