Where Online Learning is simpler!
The C and C++ Include Header Files
/usr/include/ntirpc/rpc/work_pool.h
$ cat -n /usr/include/ntirpc/rpc/work_pool.h 1 /* 2 * Copyright (c) 2013-2015 CohortFS, LLC. 3 * Copyright (c) 2013-2018 Red Hat, Inc. and/or its affiliates. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27 /** 28 * @file work_pool.h 29 * @author William Allen Simpson
30 * @brief Pthreads-based work queue package 31 * 32 * @section DESCRIPTION 33 * 34 * This provides simple work queues using pthreads and TAILQ primitives. 35 * 36 * @note Loosely based upon previous thrdpool by 37 * Matt Benjamin
38 */ 39 40 #ifndef WORK_POOL_H 41 #define WORK_POOL_H 42 43 #include
44 45 struct work_pool_params { 46 int32_t thrd_max; 47 int32_t thrd_min; 48 }; 49 50 struct work_pool_thread; 51 52 struct work_pool { 53 struct poolq_head pqh; 54 TAILQ_HEAD(work_pool_s, work_pool_thread) wptqh; 55 char *name; 56 pthread_attr_t attr; 57 struct work_pool_params params; 58 long timeout_ms; 59 uint32_t n_threads; 60 uint32_t worker_index; 61 }; 62 63 struct work_pool_entry; 64 65 struct work_pool_thread { 66 struct poolq_entry pqe; /*** 1st ***/ 67 TAILQ_ENTRY(work_pool_thread) wptq; 68 pthread_cond_t pqcond; 69 70 struct work_pool *pool; 71 struct work_pool_entry *work; 72 char worker_name[16]; 73 pthread_t pt; 74 uint32_t worker_index; 75 bool wakeup; 76 }; 77 78 typedef void (*work_pool_fun_t) (struct work_pool_entry *); 79 80 struct work_pool_entry { 81 struct poolq_entry pqe; /*** 1st ***/ 82 struct work_pool_thread *wpt; 83 work_pool_fun_t fun; 84 void *arg; 85 }; 86 87 int work_pool_init(struct work_pool *, const char *, struct work_pool_params *); 88 int work_pool_submit(struct work_pool *, struct work_pool_entry *); 89 int work_pool_shutdown(struct work_pool *); 90 91 #endif /* WORK_POOL_H */
Contact us
|
About us
|
Term of use
|
Copyright © 2000-2025 MyWebUniversity.com ™