aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/worker_queue.h
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2023-05-15 15:31:33 +0200
committerEgor Tensin <Egor.Tensin@gmail.com>2023-05-15 15:32:17 +0200
commit7cd83e15139447156ca915ce2d9d19295c146d56 (patch)
tree277f35dcc6c59d93cf5ef0232daa525079342f97 /src/worker_queue.h
parentcommand: adjust order of parameters to handlers (diff)
downloadcimple-7cd83e15139447156ca915ce2d9d19295c146d56.tar.gz
cimple-7cd83e15139447156ca915ce2d9d19295c146d56.zip
rework server-worker communication
OK, this is a major rework. * tcp_server: connection threads are not detached anymore, the caller has to clean them up. This was done so that the server can clean up the threads cleanly. * run_queue: simple refactoring, run_queue_entry is called just run now. * server: worker threads are now killed when a run is assigned to a worker. * worker: the connection to server is no longer persistent. A worker sends "new-worker", waits for a task, closes the connection, and when it's done, sends the "complete" message and waits for a new task. This is supposed to improve resilience, since the worker-server connections don't have to be maintained while the worker is doing a CI run.
Diffstat (limited to 'src/worker_queue.h')
-rw-r--r--src/worker_queue.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/worker_queue.h b/src/worker_queue.h
new file mode 100644
index 0000000..826cf65
--- /dev/null
+++ b/src/worker_queue.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2023 Egor Tensin <Egor.Tensin@gmail.com>
+ * This file is part of the "cimple" project.
+ * For details, see https://github.com/egor-tensin/cimple.
+ * Distributed under the MIT License.
+ */
+
+#ifndef __WORKER_QUEUE_H__
+#define __WORKER_QUEUE_H__
+
+#include <sys/queue.h>
+
+struct worker;
+
+int worker_create(struct worker **, int fd);
+void worker_destroy(struct worker *);
+
+int worker_get_fd(const struct worker *);
+
+STAILQ_HEAD(worker_queue, worker);
+
+void worker_queue_create(struct worker_queue *);
+void worker_queue_destroy(struct worker_queue *);
+
+int worker_queue_is_empty(const struct worker_queue *);
+
+void worker_queue_add_first(struct worker_queue *, struct worker *);
+void worker_queue_add_last(struct worker_queue *, struct worker *);
+
+struct worker *worker_queue_remove_first(struct worker_queue *);
+
+#endif