diff options
author | Igor Sysoev <igor@sysoev.ru> | 2017-01-17 20:00:00 +0300 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2017-01-17 20:00:00 +0300 |
commit | 16cbf3c076a0aca6d47adaf3f719493674cf2363 (patch) | |
tree | e6530480020f62a2bdbf249988ec3e2a751d3927 /src/nxt_fiber.h | |
download | unit-16cbf3c076a0aca6d47adaf3f719493674cf2363.tar.gz unit-16cbf3c076a0aca6d47adaf3f719493674cf2363.tar.bz2 |
Initial version.
Diffstat (limited to '')
-rw-r--r-- | src/nxt_fiber.h | 54 |
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_ */ |