Mon Oct 8 12:39:30 2012

Asterisk developer's documentation


taskprocessor.c File Reference

Maintain a container of uniquely-named taskprocessor threads that can be shared across modules. More...

#include "asterisk.h"
#include "asterisk/_private.h"
#include "asterisk/module.h"
#include "asterisk/time.h"
#include "asterisk/astobj2.h"
#include "asterisk/cli.h"
#include "asterisk/taskprocessor.h"

Go to the source code of this file.

Data Structures

struct  ast_taskprocessor
 A ast_taskprocessor structure is a singleton by name. More...
struct  ast_taskprocessor::tps_queue
 Taskprocessor queue. More...
struct  tps_task
 tps_task structure is queued to a taskprocessor More...
struct  tps_taskprocessor_stats
 tps_taskprocessor_stats maintain statistics for a taskprocessor. More...

Defines

#define TPS_MAX_BUCKETS   7

Functions

ast_taskprocessorast_taskprocessor_get (const char *name, enum ast_tps_options create)
 Get a reference to a taskprocessor with the specified name and create the taskprocessor if necessary.
const char * ast_taskprocessor_name (struct ast_taskprocessor *tps)
 Return the name of the taskprocessor singleton.
int ast_taskprocessor_push (struct ast_taskprocessor *tps, int(*task_exe)(void *datap), void *datap)
 Push a task into the specified taskprocessor queue and signal the taskprocessor thread.
void * ast_taskprocessor_unreference (struct ast_taskprocessor *tps)
 Unreference the specified taskprocessor and its reference count will decrement.
int ast_tps_init (void)
static char * cli_tps_ping (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static char * cli_tps_report (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int tps_cmp_cb (void *obj, void *arg, int flags)
 The astobj2 compare callback for taskprocessors.
static int tps_hash_cb (const void *obj, const int flags)
 The astobj2 hash callback for taskprocessors.
static int tps_ping_handler (void *datap)
 CLI taskprocessor ping <blah>

handler function.

static void * tps_processing_function (void *data)
 The task processing function executed by a taskprocessor.
static struct tps_tasktps_task_alloc (int(*task_exe)(void *datap), void *datap)
static void * tps_task_free (struct tps_task *task)
static int tps_taskprocessor_depth (struct ast_taskprocessor *tps)
 Return the size of the taskprocessor queue.
static void tps_taskprocessor_destroy (void *tps)
 Destroy the taskprocessor when its refcount reaches zero.
static struct tps_tasktps_taskprocessor_pop (struct ast_taskprocessor *tps)
 Remove the front task off the taskprocessor queue.
static char * tps_taskprocessor_tab_complete (struct ast_taskprocessor *p, struct ast_cli_args *a)

Variables

static ast_cond_t cli_ping_cond
 CLI taskprocessor ping <blah>

operation requires a ping condition.

static ast_mutex_t cli_ping_cond_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, 1 }
 CLI taskprocessor ping <blah>

operation requires a ping condition lock.

static struct ast_cli_entry taskprocessor_clis []
static struct ao2_containertps_singletons
 tps_singletons is the astobj2 container for taskprocessor singletons


Detailed Description

Maintain a container of uniquely-named taskprocessor threads that can be shared across modules.

Author:
Dwayne Hubbard <dhubbard@digium.com>

Definition in file taskprocessor.c.


Define Documentation

#define TPS_MAX_BUCKETS   7

Definition at line 87 of file taskprocessor.c.

Referenced by ast_tps_init().


Function Documentation

struct ast_taskprocessor* ast_taskprocessor_get ( const char *  name,
enum ast_tps_options  create 
)

Get a reference to a taskprocessor with the specified name and create the taskprocessor if necessary.

The default behavior of instantiating a taskprocessor if one does not already exist can be disabled by specifying the TPS_REF_IF_EXISTS ast_tps_options as the second argument to ast_taskprocessor_get().

Parameters:
name The name of the taskprocessor
create Use 0 by default or specify TPS_REF_IF_EXISTS to return NULL if the taskprocessor does not already exist return A pointer to a reference counted taskprocessor under normal conditions, or NULL if the TPS_REF_IF_EXISTS reference type is specified and the taskprocessor does not exist
Since:
1.6.1

Definition at line 413 of file taskprocessor.c.

References ao2_alloc, ao2_find, ao2_link, ao2_lock, ao2_ref, ao2_unlock, ast_calloc, ast_cond_init, ast_log(), ast_mutex_init, ast_pthread_create, AST_PTHREADT_NULL, ast_strdup, ast_strlen_zero(), LOG_ERROR, LOG_WARNING, ast_taskprocessor::name, OBJ_POINTER, tps_processing_function(), TPS_REF_IF_EXISTS, tps_singletons, and tps_taskprocessor_destroy().

Referenced by ast_cc_init(), ast_event_init(), cli_tps_ping(), load_module(), load_objects(), and load_pbx().

00414 {
00415    struct ast_taskprocessor *p, tmp_tps = {
00416       .name = name,
00417    };
00418       
00419    if (ast_strlen_zero(name)) {
00420       ast_log(LOG_ERROR, "requesting a nameless taskprocessor!!!\n");
00421       return NULL;
00422    }
00423    ao2_lock(tps_singletons);
00424    p = ao2_find(tps_singletons, &tmp_tps, OBJ_POINTER);
00425    if (p) {
00426       ao2_unlock(tps_singletons);
00427       return p;
00428    }
00429    if (create & TPS_REF_IF_EXISTS) {
00430       /* calling function does not want a new taskprocessor to be created if it doesn't already exist */
00431       ao2_unlock(tps_singletons);
00432       return NULL;
00433    }
00434    /* create a new taskprocessor */
00435    if (!(p = ao2_alloc(sizeof(*p), tps_taskprocessor_destroy))) {
00436       ao2_unlock(tps_singletons);
00437       ast_log(LOG_WARNING, "failed to create taskprocessor '%s'\n", name);
00438       return NULL;
00439    }
00440 
00441    ast_cond_init(&p->poll_cond, NULL);
00442    ast_mutex_init(&p->taskprocessor_lock);
00443 
00444    if (!(p->stats = ast_calloc(1, sizeof(*p->stats)))) {
00445       ao2_unlock(tps_singletons);
00446       ast_log(LOG_WARNING, "failed to create taskprocessor stats for '%s'\n", name);
00447       ao2_ref(p, -1);
00448       return NULL;
00449    }
00450    if (!(p->name = ast_strdup(name))) {
00451       ao2_unlock(tps_singletons);
00452       ao2_ref(p, -1);
00453       return NULL;
00454    }
00455    p->poll_thread_run = 1;
00456    p->poll_thread = AST_PTHREADT_NULL;
00457    if (ast_pthread_create(&p->poll_thread, NULL, tps_processing_function, p) < 0) {
00458       ao2_unlock(tps_singletons);
00459       ast_log(LOG_ERROR, "Taskprocessor '%s' failed to create the processing thread.\n", p->name);
00460       ao2_ref(p, -1);
00461       return NULL;
00462    }
00463    if (!(ao2_link(tps_singletons, p))) {
00464       ao2_unlock(tps_singletons);
00465       ast_log(LOG_ERROR, "Failed to add taskprocessor '%s' to container\n", p->name);
00466       ao2_ref(p, -1);
00467       return NULL;
00468    }
00469    ao2_unlock(tps_singletons);
00470    return p;
00471 }

const char* ast_taskprocessor_name ( struct ast_taskprocessor tps  ) 

Return the name of the taskprocessor singleton.

Since:
1.6.1

Definition at line 401 of file taskprocessor.c.

References ast_log(), LOG_ERROR, and ast_taskprocessor::name.

00402 {
00403    if (!tps) {
00404       ast_log(LOG_ERROR, "no taskprocessor specified!\n");
00405       return NULL;
00406    }
00407    return tps->name;
00408 }

int ast_taskprocessor_push ( struct ast_taskprocessor tps,
int(*)(void *datap)  task_exe,
void *  datap 
)

Push a task into the specified taskprocessor queue and signal the taskprocessor thread.

Parameters:
tps The taskprocessor structure
task_exe The task handling function to push into the taskprocessor queue
datap The data to be used by the task handling function
Return values:
0 success
-1 failure
Since:
1.6.1

Definition at line 488 of file taskprocessor.c.

References ast_cond_signal, AST_LIST_INSERT_TAIL, ast_log(), ast_mutex_lock, ast_mutex_unlock, LOG_ERROR, ast_taskprocessor::name, ast_taskprocessor::poll_cond, ast_taskprocessor::taskprocessor_lock, ast_taskprocessor::tps_queue, ast_taskprocessor::tps_queue_size, and tps_task_alloc().

Referenced by ast_cc_agent_status_response(), ast_cc_monitor_failed(), ast_cc_monitor_party_b_free(), ast_cc_monitor_status_request(), ast_cc_monitor_stop_ringing(), ast_event_queue(), cc_request_state_change(), cli_tps_ping(), device_state_cb(), generic_agent_devstate_cb(), generic_monitor_devstate_cb(), handle_cc_status(), iax2_transmit(), mwi_sub_event_cb(), and mwi_unsub_event_cb().

00489 {
00490    struct tps_task *t;
00491 
00492    if (!tps || !task_exe) {
00493       ast_log(LOG_ERROR, "%s is missing!!\n", (tps) ? "task callback" : "taskprocessor");
00494       return -1;
00495    }
00496    if (!(t = tps_task_alloc(task_exe, datap))) {
00497       ast_log(LOG_ERROR, "failed to allocate task!  Can't push to '%s'\n", tps->name);
00498       return -1;
00499    }
00500    ast_mutex_lock(&tps->taskprocessor_lock);
00501    AST_LIST_INSERT_TAIL(&tps->tps_queue, t, list);
00502    tps->tps_queue_size++;
00503    ast_cond_signal(&tps->poll_cond);
00504    ast_mutex_unlock(&tps->taskprocessor_lock);
00505    return 0;
00506 }

void* ast_taskprocessor_unreference ( struct ast_taskprocessor tps  ) 

Unreference the specified taskprocessor and its reference count will decrement.

Taskprocessors use astobj2 and will unlink from the taskprocessor singleton container and destroy themself when the taskprocessor reference count reaches zero.

Parameters:
tps taskprocessor to unreference
Returns:
NULL
Since:
1.6.1

Definition at line 474 of file taskprocessor.c.

References ao2_link, ao2_lock, ao2_ref, ao2_unlink, ao2_unlock, and tps_singletons.

Referenced by __unload_module(), and unload_module().

00475 {
00476    if (tps) {
00477       ao2_lock(tps_singletons);
00478       ao2_unlink(tps_singletons, tps);
00479       if (ao2_ref(tps, -1) > 1) {
00480          ao2_link(tps_singletons, tps);
00481       }
00482       ao2_unlock(tps_singletons);
00483    }
00484    return NULL;
00485 }

int ast_tps_init ( void   ) 

Provided by taskprocessor.c

Definition at line 126 of file taskprocessor.c.

References ao2_container_alloc, ARRAY_LEN, ast_cli_register_multiple(), ast_cond_init, ast_log(), cli_ping_cond, LOG_ERROR, taskprocessor_clis, tps_cmp_cb(), tps_hash_cb(), TPS_MAX_BUCKETS, and tps_singletons.

Referenced by main().

00127 {
00128    if (!(tps_singletons = ao2_container_alloc(TPS_MAX_BUCKETS, tps_hash_cb, tps_cmp_cb))) {
00129       ast_log(LOG_ERROR, "taskprocessor container failed to initialize!\n");
00130       return -1;
00131    }
00132 
00133    ast_cond_init(&cli_ping_cond, NULL);
00134 
00135    ast_cli_register_multiple(taskprocessor_clis, ARRAY_LEN(taskprocessor_clis));
00136    return 0;
00137 }

static char * cli_tps_ping ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
) [static]

Definition at line 194 of file taskprocessor.c.

References ao2_ref, ast_cli_args::argc, ast_cli_args::argv, ast_cli(), ast_cond_timedwait, ast_mutex_lock, ast_mutex_unlock, ast_samp2tv(), ast_taskprocessor_get(), ast_taskprocessor_push(), ast_tvadd(), ast_tvnow(), ast_tvsub(), CLI_FAILURE, CLI_GENERATE, CLI_INIT, cli_ping_cond, cli_ping_cond_lock, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, ast_cli_args::fd, name, tps_ping_handler(), TPS_REF_IF_EXISTS, tps_taskprocessor_tab_complete(), and ast_cli_entry::usage.

00195 {
00196    struct timeval begin, end, delta;
00197    const char *name;
00198    struct timeval when;
00199    struct timespec ts;
00200    struct ast_taskprocessor *tps = NULL;
00201 
00202    switch (cmd) {
00203    case CLI_INIT:
00204       e->command = "core ping taskprocessor";
00205       e->usage = 
00206          "Usage: core ping taskprocessor <taskprocessor>\n"
00207          "  Displays the time required for a task to be processed\n";
00208       return NULL;
00209    case CLI_GENERATE:
00210       return tps_taskprocessor_tab_complete(tps, a);
00211    }
00212 
00213    if (a->argc != 4)
00214       return CLI_SHOWUSAGE;
00215 
00216    name = a->argv[3];
00217    if (!(tps = ast_taskprocessor_get(name, TPS_REF_IF_EXISTS))) {
00218       ast_cli(a->fd, "\nping failed: %s not found\n\n", name);
00219       return CLI_SUCCESS;
00220    }
00221    ast_cli(a->fd, "\npinging %s ...", name);
00222    when = ast_tvadd((begin = ast_tvnow()), ast_samp2tv(1000, 1000));
00223    ts.tv_sec = when.tv_sec;
00224    ts.tv_nsec = when.tv_usec * 1000;
00225    ast_mutex_lock(&cli_ping_cond_lock);
00226    if (ast_taskprocessor_push(tps, tps_ping_handler, 0) < 0) {
00227       ast_cli(a->fd, "\nping failed: could not push task to %s\n\n", name);
00228       ao2_ref(tps, -1);
00229       return CLI_FAILURE;
00230    }
00231    ast_cond_timedwait(&cli_ping_cond, &cli_ping_cond_lock, &ts);
00232    ast_mutex_unlock(&cli_ping_cond_lock);
00233    end = ast_tvnow();
00234    delta = ast_tvsub(end, begin);
00235    ast_cli(a->fd, "\n\t%24s ping time: %.1ld.%.6ld sec\n\n", name, (long)delta.tv_sec, (long int)delta.tv_usec);
00236    ao2_ref(tps, -1);
00237    return CLI_SUCCESS;  
00238 }

static char * cli_tps_report ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
) [static]

Definition at line 240 of file taskprocessor.c.

References tps_taskprocessor_stats::_tasks_processed_count, ao2_container_count(), ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, ast_cli_args::argc, ast_cli_entry::args, ast_cli(), ast_copy_string(), CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, ast_cli_args::fd, tps_taskprocessor_stats::max_qsize, ast_taskprocessor::name, name, ast_taskprocessor::stats, ast_taskprocessor::tps_queue_size, tps_singletons, and ast_cli_entry::usage.

00241 {
00242    char name[256];
00243    int tcount;
00244    unsigned long qsize;
00245    unsigned long maxqsize;
00246    unsigned long processed;
00247    struct ast_taskprocessor *p;
00248    struct ao2_iterator i;
00249 
00250    switch (cmd) {
00251    case CLI_INIT:
00252       e->command = "core show taskprocessors";
00253       e->usage = 
00254          "Usage: core show taskprocessors\n"
00255          "  Shows a list of instantiated task processors and their statistics\n";
00256       return NULL;
00257    case CLI_GENERATE:
00258       return NULL;   
00259    }
00260 
00261    if (a->argc != e->args)
00262       return CLI_SHOWUSAGE;
00263 
00264    ast_cli(a->fd, "\n\t+----- Processor -----+--- Processed ---+- In Queue -+- Max Depth -+");
00265    i = ao2_iterator_init(tps_singletons, 0);
00266    while ((p = ao2_iterator_next(&i))) {
00267       ast_copy_string(name, p->name, sizeof(name));
00268       qsize = p->tps_queue_size;
00269       maxqsize = p->stats->max_qsize;
00270       processed = p->stats->_tasks_processed_count;
00271       ast_cli(a->fd, "\n%24s   %17ld %12ld %12ld", name, processed, qsize, maxqsize);
00272       ao2_ref(p, -1);
00273    }
00274    ao2_iterator_destroy(&i);
00275    tcount = ao2_container_count(tps_singletons); 
00276    ast_cli(a->fd, "\n\t+---------------------+-----------------+------------+-------------+\n\t%d taskprocessors\n\n", tcount);
00277    return CLI_SUCCESS;  
00278 }

static int tps_cmp_cb ( void *  obj,
void *  arg,
int  flags 
) [static]

The astobj2 compare callback for taskprocessors.

Definition at line 344 of file taskprocessor.c.

References CMP_MATCH, CMP_STOP, and ast_taskprocessor::name.

Referenced by ast_tps_init().

00345 {
00346    struct ast_taskprocessor *lhs = obj, *rhs = arg;
00347 
00348    return !strcasecmp(lhs->name, rhs->name) ? CMP_MATCH | CMP_STOP : 0;
00349 }

static int tps_hash_cb ( const void *  obj,
const int  flags 
) [static]

The astobj2 hash callback for taskprocessors.

Definition at line 336 of file taskprocessor.c.

References ast_str_case_hash(), and ast_taskprocessor::name.

Referenced by ast_tps_init().

00337 {
00338    const struct ast_taskprocessor *tps = obj;
00339 
00340    return ast_str_case_hash(tps->name);
00341 }

static int tps_ping_handler ( void *  datap  )  [static]

CLI taskprocessor ping <blah>

handler function.

Definition at line 185 of file taskprocessor.c.

References ast_cond_signal, ast_mutex_lock, ast_mutex_unlock, cli_ping_cond, and cli_ping_cond_lock.

Referenced by cli_tps_ping().

00186 {
00187    ast_mutex_lock(&cli_ping_cond_lock);
00188    ast_cond_signal(&cli_ping_cond);
00189    ast_mutex_unlock(&cli_ping_cond_lock);
00190    return 0;
00191 }

static void * tps_processing_function ( void *  data  )  [static]

The task processing function executed by a taskprocessor.

Definition at line 281 of file taskprocessor.c.

References tps_taskprocessor_stats::_tasks_processed_count, ast_cond_wait, ast_log(), ast_mutex_lock, ast_mutex_unlock, tps_task::datap, tps_task::execute, LOG_ERROR, LOG_WARNING, tps_taskprocessor_stats::max_qsize, ast_taskprocessor::poll_cond, ast_taskprocessor::poll_thread_run, ast_taskprocessor::stats, ast_taskprocessor::taskprocessor_lock, tps_task_free(), tps_taskprocessor_depth(), and tps_taskprocessor_pop().

Referenced by ast_taskprocessor_get().

00282 {
00283    struct ast_taskprocessor *i = data;
00284    struct tps_task *t;
00285    int size;
00286 
00287    if (!i) {
00288       ast_log(LOG_ERROR, "cannot start thread_function loop without a ast_taskprocessor structure.\n");
00289       return NULL;
00290    }
00291 
00292    while (i->poll_thread_run) {
00293       ast_mutex_lock(&i->taskprocessor_lock);
00294       if (!i->poll_thread_run) {
00295          ast_mutex_unlock(&i->taskprocessor_lock);
00296          break;
00297       }
00298       if (!(size = tps_taskprocessor_depth(i))) {
00299          ast_cond_wait(&i->poll_cond, &i->taskprocessor_lock);
00300          if (!i->poll_thread_run) {
00301             ast_mutex_unlock(&i->taskprocessor_lock);
00302             break;
00303          }
00304       }
00305       ast_mutex_unlock(&i->taskprocessor_lock);
00306       /* stuff is in the queue */
00307       if (!(t = tps_taskprocessor_pop(i))) {
00308          ast_log(LOG_ERROR, "Wtf?? %d tasks in the queue, but we're popping blanks!\n", size);
00309          continue;
00310       }
00311       if (!t->execute) {
00312          ast_log(LOG_WARNING, "Task is missing a function to execute!\n");
00313          tps_task_free(t);
00314          continue;
00315       }
00316       t->execute(t->datap);
00317  
00318       ast_mutex_lock(&i->taskprocessor_lock);
00319       if (i->stats) {
00320          i->stats->_tasks_processed_count++;
00321          if (size > i->stats->max_qsize) {
00322             i->stats->max_qsize = size;
00323          }
00324       }
00325       ast_mutex_unlock(&i->taskprocessor_lock);
00326  
00327       tps_task_free(t);
00328    }
00329    while ((t = tps_taskprocessor_pop(i))) {
00330       tps_task_free(t);
00331    }
00332    return NULL;
00333 }

static struct tps_task* tps_task_alloc ( int(*)(void *datap)  task_exe,
void *  datap 
) [static]

Definition at line 140 of file taskprocessor.c.

References ast_calloc, and tps_task::execute.

Referenced by ast_taskprocessor_push().

00141 {
00142    struct tps_task *t;
00143    if ((t = ast_calloc(1, sizeof(*t)))) {
00144       t->execute = task_exe;
00145       t->datap = datap;
00146    }
00147    return t;
00148 }

static void* tps_task_free ( struct tps_task task  )  [static]

Definition at line 151 of file taskprocessor.c.

References ast_free.

Referenced by tps_processing_function().

00152 {
00153    if (task) {
00154       ast_free(task);
00155    }
00156    return NULL;
00157 }

static int tps_taskprocessor_depth ( struct ast_taskprocessor tps  )  [static]

Return the size of the taskprocessor queue.

Definition at line 395 of file taskprocessor.c.

References ast_taskprocessor::tps_queue_size.

Referenced by tps_processing_function().

00396 {
00397    return (tps) ? tps->tps_queue_size : -1;
00398 }

static void tps_taskprocessor_destroy ( void *  tps  )  [static]

Destroy the taskprocessor when its refcount reaches zero.

Definition at line 352 of file taskprocessor.c.

References ast_cond_destroy, ast_cond_signal, ast_free, ast_log(), ast_mutex_destroy, ast_mutex_lock, ast_mutex_unlock, AST_PTHREADT_NULL, LOG_DEBUG, LOG_ERROR, ast_taskprocessor::name, ast_taskprocessor::poll_cond, ast_taskprocessor::poll_thread, ast_taskprocessor::poll_thread_run, ast_taskprocessor::stats, and ast_taskprocessor::taskprocessor_lock.

Referenced by ast_taskprocessor_get().

00353 {
00354    struct ast_taskprocessor *t = tps;
00355    
00356    if (!tps) {
00357       ast_log(LOG_ERROR, "missing taskprocessor\n");
00358       return;
00359    }
00360    ast_log(LOG_DEBUG, "destroying taskprocessor '%s'\n", t->name);
00361    /* kill it */  
00362    ast_mutex_lock(&t->taskprocessor_lock);
00363    t->poll_thread_run = 0;
00364    ast_cond_signal(&t->poll_cond);
00365    ast_mutex_unlock(&t->taskprocessor_lock);
00366    pthread_join(t->poll_thread, NULL);
00367    t->poll_thread = AST_PTHREADT_NULL;
00368    ast_mutex_destroy(&t->taskprocessor_lock);
00369    ast_cond_destroy(&t->poll_cond);
00370    /* free it */
00371    if (t->stats) {
00372       ast_free(t->stats);
00373       t->stats = NULL;
00374    }
00375    ast_free((char *) t->name);
00376 }

static struct tps_task * tps_taskprocessor_pop ( struct ast_taskprocessor tps  )  [static]

Remove the front task off the taskprocessor queue.

Definition at line 379 of file taskprocessor.c.

References AST_LIST_REMOVE_HEAD, ast_log(), ast_mutex_lock, ast_mutex_unlock, LOG_ERROR, ast_taskprocessor::taskprocessor_lock, ast_taskprocessor::tps_queue, and ast_taskprocessor::tps_queue_size.

Referenced by tps_processing_function().

00380 {
00381    struct tps_task *task;
00382 
00383    if (!tps) {
00384       ast_log(LOG_ERROR, "missing taskprocessor\n");
00385       return NULL;
00386    }
00387    ast_mutex_lock(&tps->taskprocessor_lock);
00388    if ((task = AST_LIST_REMOVE_HEAD(&tps->tps_queue, list))) {
00389       tps->tps_queue_size--;
00390    }
00391    ast_mutex_unlock(&tps->taskprocessor_lock);
00392    return task;
00393 }

static char* tps_taskprocessor_tab_complete ( struct ast_taskprocessor p,
struct ast_cli_args a 
) [static]

Definition at line 160 of file taskprocessor.c.

References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, ast_strdup, ast_cli_args::n, ast_taskprocessor::name, name, ast_cli_args::pos, tps_singletons, and ast_cli_args::word.

Referenced by cli_tps_ping().

00161 {
00162    int tklen;
00163    int wordnum = 0;
00164    char *name = NULL;
00165    struct ao2_iterator i;
00166 
00167    if (a->pos != 3)
00168       return NULL;
00169 
00170    tklen = strlen(a->word);
00171    i = ao2_iterator_init(tps_singletons, 0);
00172    while ((p = ao2_iterator_next(&i))) {
00173       if (!strncasecmp(a->word, p->name, tklen) && ++wordnum > a->n) {
00174          name = ast_strdup(p->name);
00175          ao2_ref(p, -1);
00176          break;
00177       }
00178       ao2_ref(p, -1);
00179    }
00180    ao2_iterator_destroy(&i);
00181    return name;
00182 }


Variable Documentation

ast_cond_t cli_ping_cond [static]

CLI taskprocessor ping <blah>

operation requires a ping condition.

Definition at line 92 of file taskprocessor.c.

Referenced by ast_tps_init(), cli_tps_ping(), and tps_ping_handler().

ast_mutex_t cli_ping_cond_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, 1 } [static]

CLI taskprocessor ping <blah>

operation requires a ping condition lock.

Definition at line 95 of file taskprocessor.c.

Referenced by cli_tps_ping(), and tps_ping_handler().

struct ast_cli_entry taskprocessor_clis[] [static]

Initial value:

 {
   { .handler =  cli_tps_ping , .summary =  "Ping a named task processor" ,__VA_ARGS__ },
   { .handler =  cli_tps_report , .summary =  "List instantiated task processors and statistics" ,__VA_ARGS__ },
}

Definition at line 120 of file taskprocessor.c.

Referenced by ast_tps_init().

struct ao2_container* tps_singletons [static]

tps_singletons is the astobj2 container for taskprocessor singletons

Definition at line 89 of file taskprocessor.c.

Referenced by ast_taskprocessor_get(), ast_taskprocessor_unreference(), ast_tps_init(), cli_tps_report(), and tps_taskprocessor_tab_complete().


Generated on Mon Oct 8 12:39:30 2012 for Asterisk - The Open Source Telephony Project by  doxygen 1.4.7