forked from vieter-v/libvieter
refactor(job-queue): change free functions
parent
ec6e217801
commit
07f793d768
|
@ -38,7 +38,7 @@ typedef struct vieter_job_failure_report {
|
||||||
|
|
||||||
vieter_job_failure_report *vieter_job_failure_report_init();
|
vieter_job_failure_report *vieter_job_failure_report_init();
|
||||||
|
|
||||||
void vieter_job_failure_report_free(vieter_job_failure_report **ptp);
|
void vieter_job_failure_report_free(vieter_job_failure_report *report);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Represents a job currently being processed in the system. A job migrates
|
* Represents a job currently being processed in the system. A job migrates
|
||||||
|
@ -62,7 +62,7 @@ typedef struct vieter_job {
|
||||||
*/
|
*/
|
||||||
vieter_job *vieter_job_init();
|
vieter_job *vieter_job_init();
|
||||||
|
|
||||||
void vieter_job_free(vieter_job **ptp);
|
void vieter_job_free(vieter_job *job);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Represents the actual queue managing the list of jobs.
|
* Represents the actual queue managing the list of jobs.
|
||||||
|
@ -87,7 +87,7 @@ vieter_job_queue *vieter_job_queue_init();
|
||||||
/*
|
/*
|
||||||
* Free a job queue.
|
* Free a job queue.
|
||||||
*/
|
*/
|
||||||
void vieter_job_queue_free(vieter_job_queue **ptp);
|
void vieter_job_queue_free(vieter_job_queue *queue);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Insert the given job into the system.
|
* Insert the given job into the system.
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
#include "vieter_job_queue_internal.h"
|
||||||
|
|
||||||
|
vieter_job *vieter_job_init() { return calloc(1, sizeof(vieter_job)); }
|
||||||
|
|
||||||
|
void vieter_job_free(vieter_job *job) {
|
||||||
|
if (job->schedule != NULL) {
|
||||||
|
vieter_cron_expr_free(job->schedule);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (job->failure_report != NULL) {
|
||||||
|
vieter_job_failure_report_free(job->failure_report);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(job);
|
||||||
|
}
|
||||||
|
|
||||||
|
vieter_job_failure_report *vieter_job_failure_report_init() {
|
||||||
|
return calloc(1, sizeof(vieter_job_failure_report));
|
||||||
|
}
|
||||||
|
|
||||||
|
void vieter_job_failure_report_free(vieter_job_failure_report *report) {
|
||||||
|
free(report->msg);
|
||||||
|
free(report);
|
||||||
|
}
|
|
@ -16,9 +16,7 @@ vieter_job_queue *vieter_job_queue_init() {
|
||||||
return queue;
|
return queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vieter_job_queue_free(vieter_job_queue **ptp) {
|
void vieter_job_queue_free(vieter_job_queue *queue) {
|
||||||
vieter_job_queue *queue = *ptp;
|
|
||||||
|
|
||||||
vieter_tree_free(queue->tree);
|
vieter_tree_free(queue->tree);
|
||||||
|
|
||||||
for (int i = 0; i < VIETER_JOB_STATES; i++) {
|
for (int i = 0; i < VIETER_JOB_STATES; i++) {
|
||||||
|
@ -30,25 +28,6 @@ void vieter_job_queue_free(vieter_job_queue **ptp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
free(queue);
|
free(queue);
|
||||||
*ptp = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
vieter_job *vieter_job_init() { return calloc(1, sizeof(vieter_job)); }
|
|
||||||
|
|
||||||
void vieter_job_free(vieter_job **ptp) {
|
|
||||||
vieter_job *job = *ptp;
|
|
||||||
|
|
||||||
if (job->schedule != NULL) {
|
|
||||||
vieter_cron_expr_free(job->schedule);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (job->failure_report != NULL) {
|
|
||||||
vieter_job_failure_report_free(&job->failure_report);
|
|
||||||
}
|
|
||||||
|
|
||||||
free(job);
|
|
||||||
|
|
||||||
*ptp = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vieter_job_queue_error vieter_job_queue_insert(vieter_job_queue *queue,
|
vieter_job_queue_error vieter_job_queue_insert(vieter_job_queue *queue,
|
||||||
|
@ -160,10 +139,6 @@ vieter_job_queue_error vieter_job_queue_remove(vieter_job **out,
|
||||||
return vieter_job_queue_ok;
|
return vieter_job_queue_ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
vieter_job_failure_report *vieter_job_failure_report_init() {
|
|
||||||
return calloc(1, sizeof(vieter_job_failure_report));
|
|
||||||
}
|
|
||||||
|
|
||||||
vieter_job_queue_error vieter_job_queue_fail(vieter_job_queue *queue,
|
vieter_job_queue_error vieter_job_queue_fail(vieter_job_queue *queue,
|
||||||
uint64_t id,
|
uint64_t id,
|
||||||
char *report_message) {
|
char *report_message) {
|
||||||
|
|
Loading…
Reference in New Issue