Logo Search packages:      
Sourcecode: zebra version File versions  Download package

zebra_processor_t* zebra_processor_create ( int  threaded  ) 

constructor. if threaded is set and threading is available the processor will spawn threads where appropriate to avoid blocking and improve responsiveness

Definition at line 390 of file processor.c.

References zebra_image_scanner_create(), and zebra_processor_create().

Referenced by zebra::Processor::Processor(), and zebra_processor_create().

{
    zebra_processor_t *proc = calloc(1, sizeof(zebra_processor_t));
    if(!proc)
        return(NULL);
    err_init(&proc->err, ZEBRA_MOD_PROCESSOR);
    proc->kick_fds[0] = proc->kick_fds[1] = -1;

    proc->scanner = zebra_image_scanner_create();
    if(!proc->scanner) {
        free(proc);
        return(NULL);
    }

    if(threaded) {
#ifdef HAVE_LIBPTHREAD
        proc->threaded = 1;
        proc->sem = 1;
        /* FIXME check errors */
        pthread_mutex_init(&proc->mutex, NULL);
        pthread_cond_init(&proc->cond, NULL);
        pthread_cond_init(&proc->event, NULL);
        pipe(proc->kick_fds);
        add_poll(proc, proc->kick_fds[0], NULL);
#else
    /* FIXME record warning */
#endif
    }

    return(proc);
}


Generated by  Doxygen 1.6.0   Back to index