blob: 7d66612fd74a4f6dbec20e817711f50acd057a89 (
plain) (
tree)
|
|
/*
* 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_ */
|