diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..a2eb55d --- /dev/null +++ b/.editorconfig @@ -0,0 +1,5 @@ +root = true + +[*.{c,h}] +indent_style = space +indent_size = 2 diff --git a/Makefile b/Makefile index fadf89d..9db32d4 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,8 @@ INC_DIRS ?= include LIB := $(BUILD_DIR)/$(LIB_FILENAME) SRCS != find '$(SRC_DIR)' -iname '*.c' -SRCS_H != find $(INC_DIRS) '$(SRC_DIR)' -iname '*.h' +SRCS_H != find $(INC_DIRS) -iname '*.h' +SRCS_H_INTERNAL != find $(SRC_DIR) -iname '*.h' SRCS_TEST != find '$(TEST_DIR)' -iname '*.c' OBJS := $(SRCS:%=$(BUILD_DIR)/%.o) @@ -86,11 +87,11 @@ $(BUILD_DIR)/$(TEST_DIR)/%.c.o: $(TEST_DIR)/%.c # =====MAINTENANCE===== .PHONY: lint lint: - clang-format -n --Werror $(SRCS) $(SRCS_H) + clang-format -n --Werror $(SRCS) $(SRCS_H) $(SRCS_H_INTERNAL) .PHONY: fmt fmt: - clang-format -i $(SRCS) $(SRCS_H) + clang-format -i $(SRCS) $(SRCS_H) $(SRCS_H_INTERNAL) .PHONY: clean clean: diff --git a/include/vieter_job_queue.h b/include/vieter_job_queue.h index 6c21da0..fc02d7e 100644 --- a/include/vieter_job_queue.h +++ b/include/vieter_job_queue.h @@ -1,9 +1,9 @@ #ifndef VIETER_JOB_QUEUE #define VIETER_JOB_QUEUE -#include -#include #include "vieter_cron.h" +#include +#include /* * The order of these do not imply that they happen in this order. New states @@ -12,21 +12,29 @@ * other things. */ typedef enum vieter_job_state { - vieter_job_queued = 0, - vieter_job_dispatched = 1, - vieter_job_finished = 2 + vieter_job_state_queued = 0, + vieter_job_state_ready = 1, + vieter_job_state_build_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]; + 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; } vieter_job; +typedef struct vieter_job_queue vieter_job_queue; + +vieter_job_queue *vieter_job_queue_init(); + +void vieter_job_queue_insert(int id); + #endif diff --git a/src/job-queue/vieter_job_queue_internal.h b/src/job-queue/vieter_job_queue_internal.h new file mode 100644 index 0000000..8d8ffc4 --- /dev/null +++ b/src/job-queue/vieter_job_queue_internal.h @@ -0,0 +1,10 @@ +#ifndef VIETER_JOB_QUEUE_INTERNAL +#define VIETER_JOB_QUEUE_INTERNAL + +#include "vieter_tree.h" + +struct vieter_job_queue { + vieter_tree *tree; +}; + +#endif