Mercurial > hg > nginx-quic
annotate src/core/ngx_rbtree.h @ 6038:94ce52db3367
Removed stub implementation of win32 mutexes.
author | Ruslan Ermilov <ru@nginx.com> |
---|---|
date | Mon, 23 Mar 2015 13:52:47 +0300 |
parents | 1f513d7f1b45 |
children | e0cc454aafe4 |
rev | line source |
---|---|
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
209
diff
changeset
|
1 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
209
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
4412 | 4 * Copyright (C) Nginx, Inc. |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
209
diff
changeset
|
5 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
209
diff
changeset
|
6 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
209
diff
changeset
|
7 |
205
4a9a2b1dd6fa
nginx-0.0.1-2003-12-04-17:53:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #ifndef _NGX_RBTREE_H_INCLUDED_ |
4a9a2b1dd6fa
nginx-0.0.1-2003-12-04-17:53:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 #define _NGX_RBTREE_H_INCLUDED_ |
4a9a2b1dd6fa
nginx-0.0.1-2003-12-04-17:53:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 |
4a9a2b1dd6fa
nginx-0.0.1-2003-12-04-17:53:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
4a9a2b1dd6fa
nginx-0.0.1-2003-12-04-17:53:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
12 #include <ngx_config.h> |
4a9a2b1dd6fa
nginx-0.0.1-2003-12-04-17:53:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
13 #include <ngx_core.h> |
4a9a2b1dd6fa
nginx-0.0.1-2003-12-04-17:53:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
14 |
4a9a2b1dd6fa
nginx-0.0.1-2003-12-04-17:53:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
15 |
557 | 16 typedef ngx_uint_t ngx_rbtree_key_t; |
17 typedef ngx_int_t ngx_rbtree_key_int_t; | |
18 | |
19 | |
559 | 20 typedef struct ngx_rbtree_node_s ngx_rbtree_node_t; |
205
4a9a2b1dd6fa
nginx-0.0.1-2003-12-04-17:53:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
21 |
559 | 22 struct ngx_rbtree_node_s { |
23 ngx_rbtree_key_t key; | |
24 ngx_rbtree_node_t *left; | |
25 ngx_rbtree_node_t *right; | |
26 ngx_rbtree_node_t *parent; | |
853 | 27 u_char color; |
28 u_char data; | |
205
4a9a2b1dd6fa
nginx-0.0.1-2003-12-04-17:53:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
29 }; |
4a9a2b1dd6fa
nginx-0.0.1-2003-12-04-17:53:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
30 |
207
6e0fef527732
nginx-0.0.1-2003-12-05-20:07:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
206
diff
changeset
|
31 |
559 | 32 typedef struct ngx_rbtree_s ngx_rbtree_t; |
33 | |
853 | 34 typedef void (*ngx_rbtree_insert_pt) (ngx_rbtree_node_t *root, |
559 | 35 ngx_rbtree_node_t *node, ngx_rbtree_node_t *sentinel); |
36 | |
37 struct ngx_rbtree_s { | |
38 ngx_rbtree_node_t *root; | |
39 ngx_rbtree_node_t *sentinel; | |
853 | 40 ngx_rbtree_insert_pt insert; |
559 | 41 }; |
205
4a9a2b1dd6fa
nginx-0.0.1-2003-12-04-17:53:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
42 |
4a9a2b1dd6fa
nginx-0.0.1-2003-12-04-17:53:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
43 |
1686 | 44 #define ngx_rbtree_init(tree, s, i) \ |
45 ngx_rbtree_sentinel_init(s); \ | |
46 (tree)->root = s; \ | |
47 (tree)->sentinel = s; \ | |
48 (tree)->insert = i | |
49 | |
50 | |
5894
1f513d7f1b45
Events: removed broken thread support from event timers.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
51 void ngx_rbtree_insert(ngx_rbtree_t *tree, ngx_rbtree_node_t *node); |
1f513d7f1b45
Events: removed broken thread support from event timers.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
52 void ngx_rbtree_delete(ngx_rbtree_t *tree, ngx_rbtree_node_t *node); |
861 | 53 void ngx_rbtree_insert_value(ngx_rbtree_node_t *root, ngx_rbtree_node_t *node, |
54 ngx_rbtree_node_t *sentinel); | |
853 | 55 void ngx_rbtree_insert_timer_value(ngx_rbtree_node_t *root, |
56 ngx_rbtree_node_t *node, ngx_rbtree_node_t *sentinel); | |
559 | 57 |
58 | |
1023
68cc5e2e1a5d
make global the rbtree color handling macros
Igor Sysoev <igor@sysoev.ru>
parents:
965
diff
changeset
|
59 #define ngx_rbt_red(node) ((node)->color = 1) |
68cc5e2e1a5d
make global the rbtree color handling macros
Igor Sysoev <igor@sysoev.ru>
parents:
965
diff
changeset
|
60 #define ngx_rbt_black(node) ((node)->color = 0) |
68cc5e2e1a5d
make global the rbtree color handling macros
Igor Sysoev <igor@sysoev.ru>
parents:
965
diff
changeset
|
61 #define ngx_rbt_is_red(node) ((node)->color) |
68cc5e2e1a5d
make global the rbtree color handling macros
Igor Sysoev <igor@sysoev.ru>
parents:
965
diff
changeset
|
62 #define ngx_rbt_is_black(node) (!ngx_rbt_is_red(node)) |
68cc5e2e1a5d
make global the rbtree color handling macros
Igor Sysoev <igor@sysoev.ru>
parents:
965
diff
changeset
|
63 #define ngx_rbt_copy_color(n1, n2) (n1->color = n2->color) |
68cc5e2e1a5d
make global the rbtree color handling macros
Igor Sysoev <igor@sysoev.ru>
parents:
965
diff
changeset
|
64 |
68cc5e2e1a5d
make global the rbtree color handling macros
Igor Sysoev <igor@sysoev.ru>
parents:
965
diff
changeset
|
65 |
965 | 66 /* a sentinel must be black */ |
67 | |
1023
68cc5e2e1a5d
make global the rbtree color handling macros
Igor Sysoev <igor@sysoev.ru>
parents:
965
diff
changeset
|
68 #define ngx_rbtree_sentinel_init(node) ngx_rbt_black(node) |
965 | 69 |
70 | |
559 | 71 static ngx_inline ngx_rbtree_node_t * |
72 ngx_rbtree_min(ngx_rbtree_node_t *node, ngx_rbtree_node_t *sentinel) | |
205
4a9a2b1dd6fa
nginx-0.0.1-2003-12-04-17:53:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
73 { |
557 | 74 while (node->left != sentinel) { |
75 node = node->left; | |
76 } | |
205
4a9a2b1dd6fa
nginx-0.0.1-2003-12-04-17:53:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
77 |
557 | 78 return node; |
205
4a9a2b1dd6fa
nginx-0.0.1-2003-12-04-17:53:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
79 } |
4a9a2b1dd6fa
nginx-0.0.1-2003-12-04-17:53:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
80 |
4a9a2b1dd6fa
nginx-0.0.1-2003-12-04-17:53:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
81 |
4a9a2b1dd6fa
nginx-0.0.1-2003-12-04-17:53:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
82 #endif /* _NGX_RBTREE_H_INCLUDED_ */ |