summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormrfoxygmfr <mrfoxygmfr@sch9.ru>2025-05-21 02:36:23 +0300
committermrfoxygmfr <mrfoxygmfr@sch9.ru>2025-05-21 02:36:23 +0300
commit7d4e357bac40a3ef792bb9fc25c9340c5b0131d6 (patch)
tree4d842c5e72a62eb71a9dbc892cce2da6760eda73
parent1ecdfe36f781532a862489725a8630a71079e989 (diff)
feat: add controller and worker examples
-rw-r--r--controller.c19
-rw-r--r--worker.c16
2 files changed, 35 insertions, 0 deletions
diff --git a/controller.c b/controller.c
new file mode 100644
index 0000000..6efcb7e
--- /dev/null
+++ b/controller.c
@@ -0,0 +1,19 @@
+#include "lib/controller.h"
+
+int32_t main() {
+ controller_init("127.0.0.1", "33554", 1, 4);
+ controller_start();
+
+ printf("%d\n", controller_yield_task("test", 4));
+ printf("%d\n", controller_yield_task("task", 4));
+
+ controller_wait();
+
+ const char* c;
+ size_t sz;
+ printf("%d\n", controller_get_result(&c, &sz));
+ printf("%d\n", controller_get_result(&c, &sz));
+
+ controller_finish();
+ printf("OK\n");
+}
diff --git a/worker.c b/worker.c
new file mode 100644
index 0000000..c6698d9
--- /dev/null
+++ b/worker.c
@@ -0,0 +1,16 @@
+#include "./lib/worker.h"
+
+void func(const char* task, size_t task_size, char** resp, size_t* resp_size) {
+ printf("HERE %*s\n", (int) task_size, task);
+
+ task = task;
+ task_size = task_size;
+ *resp = malloc(10);
+ *resp_size = 10;
+ sleep(1);
+}
+
+int32_t main() {
+ worker_init("127.0.0.1", "33554", 2, func);
+ worker_exec();
+}