forked from vieter-v/libvieter
fix(job-queue): use time as key for heaps
parent
1f4887118f
commit
c7d2db4e42
|
@ -60,7 +60,8 @@ vieter_job_queue_error vieter_job_queue_insert(vieter_job_queue *queue,
|
||||||
}
|
}
|
||||||
|
|
||||||
// We assume that the initial state is not a category heap
|
// We assume that the initial state is not a category heap
|
||||||
vieter_heap_insert(queue->heaps[VIETER_JOB_INITIAL_STATE].heap, job->id, job);
|
vieter_heap_insert(queue->heaps[VIETER_JOB_INITIAL_STATE].heap,
|
||||||
|
job->next_scheduled_time, job);
|
||||||
|
|
||||||
job->current_state = VIETER_JOB_INITIAL_STATE;
|
job->current_state = VIETER_JOB_INITIAL_STATE;
|
||||||
job->dispatched = false;
|
job->dispatched = false;
|
||||||
|
@ -124,10 +125,11 @@ vieter_job_queue_error vieter_job_queue_transition(vieter_job_queue *queue,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIETER_JOB_STATE_IS_ARCH(new_state)) {
|
if (VIETER_JOB_STATE_IS_ARCH(new_state)) {
|
||||||
vieter_cat_heap_insert(queue->heaps[new_state].cat_heap, job->arch, job->id,
|
vieter_cat_heap_insert(queue->heaps[new_state].cat_heap, job->arch,
|
||||||
job);
|
job->next_scheduled_time, job);
|
||||||
} else {
|
} else {
|
||||||
vieter_heap_insert(queue->heaps[new_state].heap, job->id, job);
|
vieter_heap_insert(queue->heaps[new_state].heap, job->next_scheduled_time,
|
||||||
|
job);
|
||||||
}
|
}
|
||||||
|
|
||||||
job->current_state = new_state;
|
job->current_state = new_state;
|
||||||
|
@ -178,7 +180,8 @@ vieter_job_queue_error vieter_job_queue_fail(vieter_job_queue *queue,
|
||||||
}
|
}
|
||||||
|
|
||||||
// We assume the failure state is not categorized
|
// We assume the failure state is not categorized
|
||||||
vieter_heap_insert(queue->heaps[VIETER_JOB_FAILURE_STATE].heap, job->id, job);
|
vieter_heap_insert(queue->heaps[VIETER_JOB_FAILURE_STATE].heap,
|
||||||
|
job->next_scheduled_time, job);
|
||||||
|
|
||||||
job->dispatched = false;
|
job->dispatched = false;
|
||||||
job->state_transition_times[VIETER_JOB_FAILURE_STATE] = time(NULL);
|
job->state_transition_times[VIETER_JOB_FAILURE_STATE] = time(NULL);
|
||||||
|
|
Loading…
Reference in New Issue