summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_fiber.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/nxt_fiber.h')
-rw-r--r--src/nxt_fiber.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/nxt_fiber.h b/src/nxt_fiber.h
new file mode 100644
index 00000000..7d66612f
--- /dev/null
+++ b/src/nxt_fiber.h
@@ -0,0 +1,54 @@
+
+/*
+ * Copyright (C) Igor Sysoev
+ * Copyright (C) NGINX, Inc.
+ */
+
+#ifndef _NXT_FIBER_H_INCLUDED_
+#define _NXT_FIBER_H_INCLUDED_
+
+
+typedef struct nxt_fiber_main_s nxt_fiber_main_t;
+typedef void (*nxt_fiber_start_t)(void *data);
+
+
+typedef uint32_t nxt_fid_t;
+#define nxt_fiber_id(f) (f)->fid;
+
+
+typedef struct nxt_fiber_s nxt_fiber_t;
+
+struct nxt_fiber_s {
+ jmp_buf jmp;
+ nxt_fid_t fid;
+ nxt_fiber_start_t start;
+ void *data;
+ char *stack;
+ size_t stack_size;
+ nxt_err_t err;
+
+ nxt_fiber_main_t *main;
+ nxt_fiber_t *next;
+
+ nxt_event_timer_t timer;
+};
+
+
+struct nxt_fiber_main_s {
+ nxt_fiber_t fiber;
+ nxt_fiber_t *idle;
+ size_t stack_size;
+ nxt_fid_t fid;
+};
+
+
+nxt_fiber_main_t *nxt_fiber_main_create(nxt_event_engine_t *engine);
+nxt_int_t nxt_fiber_create(nxt_fiber_start_t start, void *data, size_t stack);
+void nxt_fiber_yield(void);
+void nxt_fiber_sleep(nxt_msec_t timeout);
+void nxt_fiber_wait(void);
+void nxt_fiber_exit(nxt_fiber_t *next, void *data);
+NXT_EXPORT nxt_fiber_t *nxt_fiber_self(nxt_thread_t *thr);
+
+
+#endif /* _NXT_FIBER_H_INCLUDED_ */