xref: /unit/src/nxt_source.h (revision 0:a63ceefd6ab0)
1 
2 /*
3  * Copyright (C) Igor Sysoev
4  * Copyright (C) NGINX, Inc.
5  */
6 
7 #ifndef _NXT_SOURCE_H_INCLUDED_
8 #define _NXT_SOURCE_H_INCLUDED_
9 
10 
11 /*
12  * A source handler should store a pointer to a passed source hook, but not
13  * the hook's values themselves, because a source filter may change the values.
14  */
15 typedef struct {
16     void                *context;
17     nxt_work_handler_t  filter;
18 } nxt_source_hook_t;
19 
20 
21 typedef void (*nxt_source_handler_t)(void *source_context,
22     nxt_source_hook_t *query);
23 
24 
25 #define                                                                       \
26 nxt_source_filter(thr, wq, next, out)                                         \
27     do {                                                                      \
28         if (thr->engine->batch != 0) {                                        \
29             nxt_thread_work_queue_add(thr, wq, nxt_source_filter_handler,     \
30                                       next, out, thr->log);                   \
31                                                                               \
32         } else {                                                              \
33             (next)->filter(thr, (next)->context, out);                        \
34         }                                                                     \
35                                                                               \
36     } while (0)
37 
38 
39 NXT_EXPORT void nxt_source_filter_handler(nxt_thread_t *thr, void *obj,
40     void *data);
41 
42 
43 #endif /* _NXT_SOURCE_H_INCLUDED_ */
44