97 info->category =
"/main/taskpool/";
98 info->summary =
"Taskpool pushing test";
100 "Pushes a single task into a taskpool asynchronously and ensures it is executed.";
121 end.tv_sec = start.tv_sec + 5;
122 end.tv_nsec = start.tv_usec * 1000;
156 info->name =
"push_synchronous";
157 info->category =
"/main/taskpool/";
158 info->summary =
"Taskpool synchronous pushing test";
160 "Pushes a single task into a taskpool synchronously and ensures it is executed.";
204 struct timeval start;
209 info->name =
"push_serializer";
210 info->category =
"/main/taskpool/";
211 info->summary =
"Taskpool serializer pushing test";
213 "Pushes a single task into a taskpool serializer and ensures it is executed.";
239 end.tv_sec = start.tv_sec + 5;
240 end.tv_nsec = start.tv_usec * 1000;
281 info->name =
"push_serializer_synchronous";
282 info->category =
"/main/taskpool/";
283 info->summary =
"Taskpool serializer synchronous pushing test";
285 "Pushes a single task into a taskpool serializer synchronously and ensures it is executed.";
348 info->name =
"push_serializer_synchronous_requeue";
349 info->category =
"/main/taskpool/";
350 info->summary =
"Taskpool serializer synchronous requeueing test";
352 "Pushes a single task into a taskpool serializer synchronously and ensures it is requeued and executed.";
406 struct timeval start;
411 info->name =
"push_grow";
412 info->category =
"/main/taskpool/";
413 info->summary =
"Taskpool pushing test with auto-grow enabled";
415 "Pushes a single task into a taskpool asynchronously, ensures it is executed and the pool grows.";
448 end.tv_sec = start.tv_sec + 5;
449 end.tv_nsec = start.tv_usec * 1000;
480 struct timeval start;
486 info->name =
"push_shrink";
487 info->category =
"/main/taskpool/";
488 info->summary =
"Taskpool pushing test with auto-shrink enabled";
490 "Pushes a single task into a taskpool asynchronously, ensures it is executed and the pool shrinks.";
528 end.tv_sec = start.tv_sec + 1;
529 end.tv_nsec = start.tv_usec * 1000;
592 .num_tasks_executed = 0,
595 struct timeval start;
601 e->
command =
"taskpool push efficiency";
603 "Usage: taskpool push efficiency\n"
604 " Pushes 200 tasks to a taskpool and measures\n"
605 " the number of tasks executed within 30 seconds.\n";
624 for (i = 0; i < 200; i++) {
634 end.tv_sec = start.tv_sec + 30;
635 end.tv_nsec = start.tv_usec * 1000;
698 struct timeval start;
701 int num_tasks_executed = 0;
706 e->
command =
"taskpool push serializer efficiency";
708 "Usage: taskpool push serializer efficiency\n"
709 " Pushes 200 tasks to a taskpool in serializers and measures\n"
710 " the number of tasks executed within 30 seconds.\n";
720 memset(&etd, 0,
sizeof(etd));
728 for (i = 0; i < 200; i++) {
748 for (i = 0; i < 200; i++) {
756 end.tv_sec = start.tv_sec + 30;
757 end.tv_nsec = start.tv_usec * 1000;
765 ast_cli(
a->fd,
"Total tasks executed in 30 seconds: %d\n", num_tasks_executed);
770 for (i = 0; i < 200; i++) {
Asterisk main include file. File version handling, generic pbx functions.
#define ast_calloc(num, len)
A wrapper for calloc()
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
Standard Command Line Interface.
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
#define AST_CLI_DEFINE(fn, txt,...)
void ast_cli(int fd, const char *fmt,...)
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Support for logging to various files, console and syslog Configuration in file logger....
Asterisk locking-related definitions:
#define ast_cond_destroy(cond)
#define ast_cond_init(cond, attr)
#define ast_cond_timedwait(cond, mutex, time)
#define ast_mutex_init(pmutex)
#define ast_mutex_unlock(a)
int ast_atomic_fetchadd_int(volatile int *p, int v)
Atomically add v to *p and return the previous value of *p.
pthread_cond_t ast_cond_t
#define SCOPED_MUTEX(varname, lock)
scoped lock specialization for mutexes
#define ast_mutex_destroy(a)
#define ast_mutex_lock(a)
#define ast_cond_signal(cond)
Asterisk module definitions.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_SUCCESS
descriptor for a cli entry.
Structure for mutex and tracking information.
An opaque taskpool structure.
A ast_taskprocessor structure is a singleton by name.
struct ast_taskpool * pool
struct ast_taskprocessor * serializer[2]
Sorcery object created based on backend data.
struct ast_taskprocessor * taskprocessor
#define AST_TASKPOOL_OPTIONS_VERSION
size_t ast_taskpool_taskprocessors_count(struct ast_taskpool *pool)
Get the current number of taskprocessors in the taskpool.
struct ast_taskprocessor * ast_taskpool_serializer(const char *name, struct ast_taskpool *pool)
Serialized execution of tasks within a ast_taskpool.
void ast_taskpool_shutdown(struct ast_taskpool *pool)
Shut down a taskpool and remove the underlying taskprocessors.
struct ast_taskprocessor * ast_taskpool_serializer_get_current(void)
Get the taskpool serializer currently associated with this thread.
int ast_taskpool_push(struct ast_taskpool *pool, int(*task)(void *data), void *data) attribute_warn_unused_result
Push a task to the taskpool.
int ast_taskpool_serializer_push_wait(struct ast_taskprocessor *serializer, int(*task)(void *data), void *data)
Push a task to a serializer, and wait for completion.
struct ast_taskpool * ast_taskpool_create(const char *name, const struct ast_taskpool_options *options)
Create a new taskpool.
int ast_taskpool_push_wait(struct ast_taskpool *pool, int(*task)(void *data), void *data) attribute_warn_unused_result
Push a task to the taskpool, and wait for completion.
An API for managing task processing threads that can be shared across modules.
void * ast_taskprocessor_unreference(struct ast_taskprocessor *tps)
Unreference the specified taskprocessor and its reference count will decrement.
int ast_taskprocessor_push(struct ast_taskprocessor *tps, int(*task_exe)(void *datap), void *datap) attribute_warn_unused_result
Push a task into the specified taskprocessor queue and signal the taskprocessor thread.
void ast_taskprocessor_build_name(char *buf, unsigned int size, const char *format,...)
Build a taskprocessor name with a sequence number on the end.
#define AST_TASKPROCESSOR_MAX_NAME
Suggested maximum taskprocessor name length (less null terminator).
#define AST_TEST_REGISTER(cb)
#define ast_test_status_update(a, b, c...)
#define AST_TEST_UNREGISTER(cb)
static struct test_data * test_alloc(void)
static char * handle_cli_taskpool_push_efficiency(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int requeue_task(void *data)
static int serializer_efficiency_task(void *data)
static void test_destroy(struct test_data *td)
static struct ast_cli_entry cli[]
static int load_module(void)
static char * handle_cli_taskpool_push_serializer_efficiency(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int unload_module(void)
AST_TEST_DEFINE(taskpool_push)
static int simple_task(void *data)
static int efficiency_task(void *data)
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().