void queue_insert_event(event_queue_t* queue, event_t* event) { if (dbg_active(DBG_QUEUE)) { char ftime[128]; ftime[0] = 0; printOtherTime(ftime, 128, event->time); dbg(DBG_QUEUE, "Inserting event with time %s.\n", ftime); } pthread_mutex_lock(&(queue->lock)); heap_insert(&(queue->heap), event, event->time); pthread_mutex_unlock(&(queue->lock)); }
event_t* queue_pop_event(event_queue_t* queue) { long long ftime; event_t* event; pthread_mutex_lock(&(queue->lock)); event = (event_t*)(heap_pop_min_data(&(queue->heap), &ftime)); pthread_mutex_unlock(&(queue->lock)); if(dbg_active(DBG_QUEUE)) { char timeStr[128]; timeStr[0] = 0; printOtherTime(timeStr, 128, ftime); dbg(DBG_QUEUE, "Popping event for mote %i with time %s.\n", event->mote, timeStr); } if (queue->pause > 0 && event->pause) { sleep(queue->pause); //dbg(DBG_ALL, "\n"); } return event; }
int printTime(char* buf, int len) { return printOtherTime(buf, len, tos_state.tos_time); }