blob: 0bbad0b88b48d418043fe6196c74de2d46edafb5 [file] [log] [blame]
anjana_sreekumar@infosys.com991c2062020-01-08 11:42:57 +05301/*
2 * Copyright (c) 2003-2018, Great Software Laboratory Pvt. Ltd.
3 * Copyright (c) 2017 Intel Corporation
4 * Copyright (c) 2019, Infosys Ltd.
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19#ifndef __THREAD_POOL_H
20#define __THREAD_POOL_H
21
22#ifdef __cplusplus
23extern "C"{
24#endif
25
26struct thread_pool;
27typedef void (* JobFunction) (void *);
28
29/*
30 * Creates new thread pool
31 * on success return pointer to thread_pool
32 * on failure return NULL
33 */
34extern struct thread_pool *thread_pool_new(int count);
35
36/*
37 * Stops all threads and
38 * destroy the thread pool
39 * on success return 0
40 * on failure return -1
41 */
42extern int thread_pool_destroy(struct thread_pool *pool);
43
44/*
45 * Queues the job to thread pool
46 * idle threads will pick the job
47 * on success it return 0
48 * on failure returns -ve values
49 */
50extern int insert_job(struct thread_pool *pool, JobFunction function,
51 void *userdata);
52
53#ifdef __cplusplus
54}
55#endif
56
57#endif
58