2023-02-02 10:10:03 +01:00
|
|
|
#ifndef VIETER_JOB_QUEUE
|
|
|
|
#define VIETER_JOB_QUEUE
|
|
|
|
|
|
|
|
#include "vieter_cron.h"
|
2023-02-02 16:14:26 +01:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
2023-02-02 10:10:03 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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 {
|
2023-02-02 16:14:26 +01:00
|
|
|
vieter_job_state_queued = 0,
|
|
|
|
vieter_job_state_ready = 1,
|
|
|
|
vieter_job_state_build_finished = 2
|
2023-02-02 10:10:03 +01:00
|
|
|
} vieter_job_state;
|
|
|
|
|
|
|
|
// This macro should be kept in sync with the above enum
|
|
|
|
#define VIETER_JOB_STATES 3
|
|
|
|
|
|
|
|
typedef struct vieter_job {
|
2023-02-02 16:14:26 +01:00
|
|
|
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];
|
|
|
|
bool dispatched;
|
|
|
|
void *build_config;
|
2023-02-02 10:10:03 +01:00
|
|
|
} vieter_job;
|
|
|
|
|
2023-02-02 16:14:26 +01:00
|
|
|
typedef struct vieter_job_queue vieter_job_queue;
|
|
|
|
|
|
|
|
vieter_job_queue *vieter_job_queue_init();
|
|
|
|
|
|
|
|
void vieter_job_queue_insert(int id);
|
|
|
|
|
2023-02-02 10:10:03 +01:00
|
|
|
#endif
|