Apache2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
h2_worker.h
Go to the documentation of this file.
1 /* Copyright 2015 greenbytes GmbH (https://www.greenbytes.de)
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8 
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef __mod_h2__h2_worker__
17 #define __mod_h2__h2_worker__
18 
19 struct h2_mplx;
20 struct h2_request;
21 struct h2_task;
22 
23 /* h2_worker is a basically a apr_thread_t that reads fromt he h2_workers
24  * task queue and runs h2_tasks it is given.
25  */
26 typedef struct h2_worker h2_worker;
27 
28 /* Invoked when the worker wants a new task to process. Will block
29  * until a h2_mplx becomes available or the worker itself
30  * gets aborted (idle timeout, for example). */
32  void *ctx,
33  struct h2_task **ptask,
34  int *psticky);
35 
36 /* Invoked just before the worker thread exits. */
37 typedef void h2_worker_done_fn(h2_worker *worker, void *ctx);
38 
39 
40 struct h2_worker {
41  int id;
47  void *ctx;
48  int aborted;
49 };
50 
56 #define H2_WORKER_LIST_SENTINEL(b) APR_RING_SENTINEL((b), h2_worker, link)
57 
63 #define H2_WORKER_LIST_EMPTY(b) APR_RING_EMPTY((b), h2_worker, link)
64 
70 #define H2_WORKER_LIST_FIRST(b) APR_RING_FIRST(b)
71 
77 #define H2_WORKER_LIST_LAST(b) APR_RING_LAST(b)
78 
84 #define H2_WORKER_LIST_INSERT_HEAD(b, e) do { \
85  h2_worker *ap__b = (e); \
86  APR_RING_INSERT_HEAD((b), ap__b, h2_worker, link); \
87  } while (0)
88 
94 #define H2_WORKER_LIST_INSERT_TAIL(b, e) do { \
95  h2_worker *ap__b = (e); \
96  APR_RING_INSERT_TAIL((b), ap__b, h2_worker, link); \
97  } while (0)
98 
104 #define H2_WORKER_NEXT(e) APR_RING_NEXT((e), link)
105 
110 #define H2_WORKER_PREV(e) APR_RING_PREV((e), link)
111 
116 #define H2_WORKER_REMOVE(e) APR_RING_REMOVE((e), link)
117 
118 
119 /* Create a new worker with given id, pool and attributes, callbacks
120  * callback parameter.
121  */
123  apr_pool_t *pool,
124  apr_threadattr_t *attr,
125  h2_worker_mplx_next_fn *get_next,
126  h2_worker_done_fn *worker_done,
127  void *ctx);
128 
130 
132 
134 
135 #endif /* defined(__mod_h2__h2_worker__) */
Definition: h2_task.h:52
apr_status_t h2_worker_destroy(h2_worker *worker)
Definition: h2_mplx.h:62
void h2_worker_done_fn(h2_worker *worker, void *ctx)
Definition: h2_worker.h:37
apr_bucket_brigade request_rec apr_pool_t * pool
Definition: mod_dav.h:556
h2_worker_done_fn * worker_done
Definition: h2_worker.h:46
Definition: h2.h:118
void h2_worker_abort(h2_worker *worker)
int id
Definition: h2_worker.h:41
int aborted
Definition: h2_worker.h:48
Definition: apr_arch_threadproc.h:42
void * ctx
Definition: h2_worker.h:47
Definition: h2_worker.h:40
APR_RING_ENTRY(h2_worker) link
int h2_worker_is_aborted(h2_worker *worker)
h2_worker * h2_worker_create(int id, apr_pool_t *pool, apr_threadattr_t *attr, h2_worker_mplx_next_fn *get_next, h2_worker_done_fn *worker_done, void *ctx)
apr_thread_t * thread
Definition: h2_worker.h:44
Definition: apr_arch_threadproc.h:50
h2_worker_mplx_next_fn * get_next
Definition: h2_worker.h:45
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
int apr_status_t
Definition: apr_errno.h:44
proxy_worker * worker
Definition: mod_proxy.h:602
apr_status_t h2_worker_mplx_next_fn(h2_worker *worker, void *ctx, struct h2_task **ptask, int *psticky)
Definition: h2_worker.h:31