20 #ifndef _ASTERISK_THREADPOOL_H 21 #define _ASTERISK_THREADPOOL_H 71 #define AST_THREADPOOL_OPTIONS_VERSION 1 117 void (*thread_start)(void);
124 void (*thread_end)(void);
int auto_increment
Number of threads to increment pool by.
void ast_threadpool_set_size(struct ast_threadpool *threadpool, unsigned int size)
Set the number of threads for the thread pool.
void(* state_changed)(struct ast_threadpool *pool, struct ast_threadpool_listener *listener, int active_threads, int idle_threads)
Indicates that the state of threads in the pool has changed.
int idle_timeout
Time limit in seconds for idle threads.
int initial_size
Number of threads the pool will start with.
int max_size
Maximum number of threads a pool may have.
struct ast_taskprocessor * ast_threadpool_serializer(const char *name, struct ast_threadpool *pool)
Serialized execution of tasks within a ast_threadpool.
struct ast_serializer_shutdown_group * ast_serializer_shutdown_group_alloc(void)
Create a serializer group shutdown control object.
static pj_pool_t * pool
Global memory pool for configuration and timers.
struct ast_taskprocessor * ast_threadpool_serializer_group(const char *name, struct ast_threadpool *pool, struct ast_serializer_shutdown_group *shutdown_group)
Serialized execution of tasks within a ast_threadpool.
void(* shutdown)(struct ast_threadpool_listener *listener)
The threadpool is shutting down.
int ast_serializer_shutdown_group_join(struct ast_serializer_shutdown_group *shutdown_group, int timeout)
Wait for the serializers in the group to shutdown with timeout.
struct ast_taskprocessor * ast_threadpool_serializer_get_current(void)
Get the threadpool serializer currently associated with this thread.
const struct ast_threadpool_listener_callbacks * callbacks
static int task(void *data)
Queued task for baseline test.
void(* emptied)(struct ast_threadpool *pool, struct ast_threadpool_listener *listener)
Indicates the threadpool's taskprocessor has become empty.
static void * listener(void *unused)
void * ast_threadpool_listener_get_user_data(const struct ast_threadpool_listener *listener)
Get the threadpool listener's user data.
static struct ast_threadpool * threadpool
Thread pool for observers.
long ast_threadpool_queue_size(struct ast_threadpool *pool)
Return the size of the threadpool's task queue.
struct ast_threadpool_listener * ast_threadpool_listener_alloc(const struct ast_threadpool_listener_callbacks *callbacks, void *user_data)
Allocate a threadpool listener.
struct ast_threadpool * ast_threadpool_create(const char *name, struct ast_threadpool_listener *listener, const struct ast_threadpool_options *options)
Create a new threadpool.
#define attribute_warn_unused_result
int ast_threadpool_push(struct ast_threadpool *pool, int(*task)(void *data), void *data) attribute_warn_unused_result
Push a task to the threadpool.
void ast_threadpool_shutdown(struct ast_threadpool *pool)
Shut down a threadpool and destroy it.
listener for a threadpool
A ast_taskprocessor structure is a singleton by name.
void(* task_pushed)(struct ast_threadpool *pool, struct ast_threadpool_listener *listener, int was_empty)
Indicates that a task was pushed to the threadpool.
An opaque threadpool structure.
static struct ast_serializer_shutdown_group * shutdown_group
Shutdown group for options serializers.