98 info->category =
"/main/taskpool/";
99 info->summary =
"Taskpool pushing test";
101 "Pushes a single task into a taskpool asynchronously and ensures it is executed.";
122 end.tv_sec = start.tv_sec + 5;
123 end.tv_nsec = start.tv_usec * 1000;
157 info->name =
"push_synchronous";
158 info->category =
"/main/taskpool/";
159 info->summary =
"Taskpool synchronous pushing test";
161 "Pushes a single task into a taskpool synchronously and ensures it is executed.";
205 struct timeval start;
210 info->name =
"push_serializer";
211 info->category =
"/main/taskpool/";
212 info->summary =
"Taskpool serializer pushing test";
214 "Pushes a single task into a taskpool serializer and ensures it is executed.";
240 end.tv_sec = start.tv_sec + 5;
241 end.tv_nsec = start.tv_usec * 1000;
282 info->name =
"push_serializer_synchronous";
283 info->category =
"/main/taskpool/";
284 info->summary =
"Taskpool serializer synchronous pushing test";
286 "Pushes a single task into a taskpool serializer synchronously and ensures it is executed.";
349 info->name =
"push_serializer_synchronous_requeue";
350 info->category =
"/main/taskpool/";
351 info->summary =
"Taskpool serializer synchronous requeueing test";
353 "Pushes a single task into a taskpool serializer synchronously and ensures it is requeued and executed.";
407 struct timeval start;
412 info->name =
"push_grow";
413 info->category =
"/main/taskpool/";
414 info->summary =
"Taskpool pushing test with auto-grow enabled";
416 "Pushes a single task into a taskpool asynchronously, ensures it is executed and the pool grows.";
449 end.tv_sec = start.tv_sec + 5;
450 end.tv_nsec = start.tv_usec * 1000;
481 struct timeval start;
487 info->name =
"push_shrink";
488 info->category =
"/main/taskpool/";
489 info->summary =
"Taskpool pushing test with auto-shrink enabled";
491 "Pushes a single task into a taskpool asynchronously, ensures it is executed and the pool shrinks.";
529 end.tv_sec = start.tv_sec + 1;
530 end.tv_nsec = start.tv_usec * 1000;
568 struct timeval start;
573 info->name =
"serializer_suspension";
574 info->category =
"/main/taskpool/";
575 info->summary =
"Taskpool serializer suspension test";
577 "Pushes a single task into a taskpool serializer asynchronously while suspended, and ensures it only executes after unsuspension.";
605 end.tv_sec = start.tv_sec + 5;
606 end.tv_nsec = start.tv_usec * 1000;
622 end.tv_sec = start.tv_sec + 5;
623 end.tv_nsec = start.tv_usec * 1000;
656 struct timeval start;
661 info->name =
"serializer_multiple_suspension";
662 info->category =
"/main/taskpool/";
663 info->summary =
"Taskpool serializer multiple suspension test";
665 "Pushes a single task into a taskpool serializer asynchronously while suspended multiple times, and ensures it only executes after unsuspension.";
694 end.tv_sec = start.tv_sec + 5;
695 end.tv_nsec = start.tv_usec * 1000;
712 end.tv_sec = start.tv_sec + 5;
713 end.tv_nsec = start.tv_usec * 1000;
758 struct timeval start;
763 info->name =
"serializer_push_wait_while_suspended_from_other_serializer";
764 info->category =
"/main/taskpool/";
765 info->summary =
"Taskpool serializer push wait while suspended from other serializer test";
767 "Pushes a single task into a taskpool serializer synchronously from another serializer while suspended, and ensures it only executes after unsuspension.";
783 if (!suspended_serializer) {
790 if (!push_serializer) {
806 end.tv_sec = start.tv_sec + 5;
807 end.tv_nsec = start.tv_usec * 1000;
823 end.tv_sec = start.tv_sec + 5;
824 end.tv_nsec = start.tv_usec * 1000;
883 .num_tasks_executed = 0,
886 struct timeval start;
892 e->
command =
"taskpool push efficiency";
894 "Usage: taskpool push efficiency\n"
895 " Pushes 200 tasks to a taskpool and measures\n"
896 " the number of tasks executed within 30 seconds.\n";
915 for (i = 0; i < 200; i++) {
925 end.tv_sec = start.tv_sec + 30;
926 end.tv_nsec = start.tv_usec * 1000;
989 struct timeval start;
992 int num_tasks_executed = 0;
997 e->
command =
"taskpool push serializer efficiency";
999 "Usage: taskpool push serializer efficiency\n"
1000 " Pushes 200 tasks to a taskpool in serializers and measures\n"
1001 " the number of tasks executed within 30 seconds.\n";
1011 memset(&etd, 0,
sizeof(etd));
1019 for (i = 0; i < 200; i++) {
1039 for (i = 0; i < 200; i++) {
1047 end.tv_sec = start.tv_sec + 30;
1048 end.tv_nsec = start.tv_usec * 1000;
1056 ast_cli(
a->fd,
"Total tasks executed in 30 seconds: %d (%d per second)\n", num_tasks_executed, num_tasks_executed / 30);
1061 for (i = 0; i < 200; i++) {
1103 AST_TEST_REGISTER(taskpool_serializer_push_wait_while_suspended_from_other_serializer);
void ast_cli_unregister_multiple(void)
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.
#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
void * test_specific_data
int ast_taskpool_serializer_unsuspend(struct ast_taskprocessor *serializer)
Unsuspend a serializer, causing tasks to be executed.
#define AST_TASKPOOL_OPTIONS_VERSION
#define ast_taskpool_push_wait(pool, task, data)
size_t ast_taskpool_taskprocessors_count(struct ast_taskpool *pool)
Get the current number of taskprocessors in the taskpool.
int ast_taskpool_serializer_suspend(struct ast_taskprocessor *serializer)
Suspend a serializer, causing tasks to be queued until unsuspended.
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.
#define ast_taskpool_serializer_push_wait(pool, task, data)
struct ast_taskpool * ast_taskpool_create(const char *name, const struct ast_taskpool_options *options)
Create a new taskpool.
#define ast_taskpool_push(pool, task, data)
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.
#define ast_taskprocessor_push(tps, task_exe, datap)
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)
#define AST_TEST_DEFINE(hdr)
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 cascade_task(void *data)
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)
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().