xref: /unit/src/nxt_source.h (revision 1:fdc027c56872)
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, task, next, out)                                   \
27     do {                                                                      \
28         if (thr->engine->batch != 0) {                                        \
29             nxt_thread_work_queue_add(thr, wq, nxt_source_filter_handler,     \
30                                       task, next, out);                       \
31                                                                               \
32         } else {                                                              \
33             (next)->filter(task, (next)->context, out);                       \
34         }                                                                     \
35                                                                               \
36     } while (0)
37 
38 
39 NXT_EXPORT void nxt_source_filter_handler(nxt_task_t *task, void *obj,
40     void *data);
41 
42 
43 #endif /* _NXT_SOURCE_H_INCLUDED_ */
44