1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
/*
* Copyright (C) Igor Sysoev
* Copyright (C) NGINX, Inc.
*/
#ifndef _NXT_EVENT_ENGINE_H_INCLUDED_
#define _NXT_EVENT_ENGINE_H_INCLUDED_
#define NXT_ENGINE_FIBERS 1
typedef struct {
nxt_fd_t fds[2];
nxt_event_fd_t event;
} nxt_event_engine_pipe_t;
struct nxt_event_engine_s {
const nxt_event_set_ops_t *event;
nxt_event_set_t *event_set;
nxt_event_timers_t timers;
nxt_task_t task;
/* The engine ID, the main engine has ID 0. */
uint32_t id;
/*
* A pipe to pass event signals to the engine, if the engine's
* underlying event facility does not support user events.
*/
nxt_event_engine_pipe_t *pipe;
nxt_work_queue_t accept_work_queue;
nxt_work_queue_t read_work_queue;
nxt_work_queue_t socket_work_queue;
nxt_work_queue_t connect_work_queue;
nxt_work_queue_t write_work_queue;
nxt_work_queue_t shutdown_work_queue;
nxt_work_queue_t close_work_queue;
nxt_locked_work_queue_t work_queue;
nxt_event_signals_t *signals;
nxt_thread_t *thread;
nxt_fiber_main_t *fibers;
uint8_t shutdown; /* 1 bit */
uint32_t batch;
uint32_t connections;
uint32_t max_connections;
nxt_queue_t listen_connections;
nxt_queue_t idle_connections;
};
NXT_EXPORT nxt_event_engine_t *nxt_event_engine_create(nxt_thread_t *thr,
const nxt_event_set_ops_t *event_set, const nxt_event_sig_t *signals,
nxt_uint_t flags, nxt_uint_t batch);
NXT_EXPORT nxt_int_t nxt_event_engine_change(nxt_thread_t *thr,
nxt_task_t *task, const nxt_event_set_ops_t *event_set, nxt_uint_t batch);
NXT_EXPORT void nxt_event_engine_free(nxt_event_engine_t *engine);
NXT_EXPORT void nxt_event_engine_start(nxt_event_engine_t *engine);
NXT_EXPORT void nxt_event_engine_post(nxt_event_engine_t *engine,
nxt_work_handler_t handler, nxt_task_t *task, void *obj, void *data,
nxt_log_t *log);
NXT_EXPORT void nxt_event_engine_signal(nxt_event_engine_t *engine,
nxt_uint_t signo);
nxt_inline nxt_event_engine_t *
nxt_thread_event_engine(void)
{
nxt_thread_t *thr;
thr = nxt_thread();
return thr->engine;
}
nxt_inline nxt_work_queue_t *
nxt_thread_main_work_queue(void)
{
nxt_thread_t *thr;
thr = nxt_thread();
return &thr->work_queue.main;
}
#endif /* _NXT_EVENT_ENGINE_H_INCLUDED_ */
|