2 * Copyright (c) 2016-present, Facebook, Inc.
5 * This source code is licensed under the BSD-style license found in the
6 * LICENSE file in the root directory of this source tree. An additional grant
7 * of patent rights can be found in the PATENTS file in the same directory.
12 #if defined (__cplusplus)
17 #include <stddef.h> /* size_t */
19 typedef struct POOL_ctx_s POOL_ctx;
22 Create a thread pool with at most `numThreads` threads.
23 `numThreads` must be at least 1.
24 The maximum number of queued jobs before blocking is `queueSize`.
25 `queueSize` must be at least 1.
26 @return : The POOL_ctx pointer on success else NULL.
28 POOL_ctx *POOL_create(size_t numThreads, size_t queueSize);
31 Free a thread pool returned by POOL_create().
33 void POOL_free(POOL_ctx *ctx);
36 The function type that can be added to a thread pool.
38 typedef void (*POOL_function)(void *);
39 /*! POOL_add_function :
40 The function type for a generic thread pool add function.
42 typedef void (*POOL_add_function)(void *, POOL_function, void *);
45 Add the job `function(opaque)` to the thread pool.
46 Possibly blocks until there is room in the queue.
47 Note : The function may be executed asynchronously, so `opaque` must live until the function has been completed.
49 void POOL_add(void *ctx, POOL_function function, void *opaque);
52 #if defined (__cplusplus)