ethereum/event/BREvent.c
/**
 * Start the handler.  It is possible that events will already be queued; they will all be
 * dispatched, in FIFO order.  If there is a periodic alarm; it will be added to the alarmClock.
 *
 * @param handler
 */
Start the handler.  It is possible that events will already be queued; they will all be
dispatched, in FIFO order.  If there is a periodic alarm; it will be added to the alarmClock.

@param handler
Start the handler . It is possible that events will already be queued ; they will all be dispatched in FIFO order . If there is a periodic alarm ; it will be added to the alarmClock . @param handler
extern void
eventHandlerStart (BREventHandler handler) {
    alarmClockCreateIfNecessary(1);
    pthread_mutex_lock(&handler->lock);
    if (PTHREAD_NULL == handler->thread) {
        if (NULL != handler->timeoutEventType.eventDispatcher) {
            handler->timeoutAlarmId = alarmClockAddAlarmPeriodic (alarmClock,
                                                                  (BREventAlarmContext) handler,
                                                                  (BREventAlarmCallback) eventHandlerAlarmCallback,
                                                                  handler->timeout);
        }
        {
            pthread_attr_t attr;
            pthread_attr_init(&attr);
            pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
            pthread_attr_setstacksize(&attr, PTHREAD_STACK_SIZE);
            pthread_create(&handler->thread, &attr, (ThreadRoutine) eventHandlerThread, handler);
             TODO: Handle an unsuccessfull call.
             assert (NULL != handler->thread);
            pthread_attr_destroy(&attr);
        }
    }
    pthread_mutex_unlock(&handler->lock);
}
extern void eventHandlerStart ( BREventHandler handler ) { alarmClockCreateIfNecessary ( 1 ) ; pthread_mutex_lock ( & handler -> lock ) ; if ( PTHREAD_NULL == handler -> thread ) { if ( NULL != handler -> timeoutEventType . eventDispatcher ) { handler -> timeoutAlarmId = alarmClockAddAlarmPeriodic ( alarmClock , ( BREventAlarmContext ) handler , ( BREventAlarmCallback ) eventHandlerAlarmCallback , handler -> timeout ) ; } { pthread_attr_t attr ; pthread_attr_init ( & attr ) ; pthread_attr_setdetachstate ( & attr , PTHREAD_CREATE_JOINABLE ) ; pthread_attr_setstacksize ( & attr , PTHREAD_STACK_SIZE ) ; pthread_create ( & handler -> thread , & attr , ( ThreadRoutine ) eventHandlerThread , handler ) ; pthread_attr_destroy ( & attr ) ; } } pthread_mutex_unlock ( & handler -> lock ) ; }
Start the handler.
Start the handler .
// If we have an timeout event dispatcher, then add an alarm. // Spawn the eventHandlerThread // "Before returning, a successful call to pthread_create() stores the ID of the new // thread in the buffer pointed to by thread; this identifier is used to refer to the // thread in subsequent calls to other pthreads functions." // // TODO: Handle an unsuccessfull call. // assert (NULL != handler->thread);