1 /* 2 * virthreadpool.h: a generic thread pool implementation 3 * 4 * Copyright (C) 2010 Hu Tao 5 * Copyright (C) 2010 Daniel P. Berrange 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library. If not, see 19 * <http://www.gnu.org/licenses/>. 20 */ 21 22 #pragma once 23 24 #include "internal.h" 25 #include "viridentity.h" 26 27 typedef struct _virThreadPool virThreadPool; 28 29 typedef void (*virThreadPoolJobFunc)(void *jobdata, void *opaque); 30 31 virThreadPool *virThreadPoolNewFull(size_t minWorkers, 32 size_t maxWorkers, 33 size_t prioWorkers, 34 virThreadPoolJobFunc func, 35 const char *name, 36 virIdentity *identity, 37 void *opaque) ATTRIBUTE_NONNULL(4); 38 39 size_t virThreadPoolGetMinWorkers(virThreadPool *pool); 40 size_t virThreadPoolGetMaxWorkers(virThreadPool *pool); 41 size_t virThreadPoolGetPriorityWorkers(virThreadPool *pool); 42 size_t virThreadPoolGetCurrentWorkers(virThreadPool *pool); 43 size_t virThreadPoolGetFreeWorkers(virThreadPool *pool); 44 size_t virThreadPoolGetJobQueueDepth(virThreadPool *pool); 45 46 void virThreadPoolFree(virThreadPool *pool); 47 48 int virThreadPoolSendJob(virThreadPool *pool, 49 unsigned int priority, 50 void *jobdata) ATTRIBUTE_NONNULL(1) 51 G_GNUC_WARN_UNUSED_RESULT; 52 53 int virThreadPoolSetParameters(virThreadPool *pool, 54 long long int minWorkers, 55 long long int maxWorkers, 56 long long int prioWorkers); 57 58 void virThreadPoolStop(virThreadPool *pool); 59 void virThreadPoolDrain(virThreadPool *pool); 60