From 75a09cc0f99bda2e72f3035b00ee1a2453ac9f00 Mon Sep 17 00:00:00 2001 From: Chewing_Bever Date: Thu, 2 Feb 2023 10:10:03 +0100 Subject: [PATCH] feat(job-queue): first draft of job struct --- include/vieter_job_queue.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 include/vieter_job_queue.h diff --git a/include/vieter_job_queue.h b/include/vieter_job_queue.h new file mode 100644 index 0000000..6c21da0 --- /dev/null +++ b/include/vieter_job_queue.h @@ -0,0 +1,32 @@ +#ifndef VIETER_JOB_QUEUE +#define VIETER_JOB_QUEUE + +#include +#include +#include "vieter_cron.h" + +/* + * The order of these do not imply that they happen in this order. New states + * will just get added as consecutive numbers. Their values should be + * monotonically increasing values, as these will be used to index arrays, among + * other things. + */ +typedef enum vieter_job_state { + vieter_job_queued = 0, + vieter_job_dispatched = 1, + vieter_job_finished = 2 +} vieter_job_state; + +// This macro should be kept in sync with the above enum +#define VIETER_JOB_STATES 3 + +typedef struct vieter_job { + int id; + uint64_t next_scheduled_time; + vieter_cron_expression *ce; + bool single; + vieter_job_state state; + uint64_t state_transition_times[VIETER_JOB_STATES]; +} vieter_job; + +#endif