Asterisk - The Open Source Telephony Project
18.5.0
|
pthread timing interface More...
#include "asterisk.h"
#include <stdbool.h>
#include <math.h>
#include <unistd.h>
#include <fcntl.h>
#include "asterisk/module.h"
#include "asterisk/timing.h"
#include "asterisk/utils.h"
#include "asterisk/astobj2.h"
#include "asterisk/time.h"
#include "asterisk/lock.h"
Go to the source code of this file.
Data Structures | |
struct | pthread_timer |
Macros | |
#define | MAX_RATE 100 |
#define | PTHREAD_TIMER_BUCKETS 563 |
Enumerations | |
enum | { PIPE_READ = 0, PIPE_WRITE = 1 } |
enum | pthread_timer_state { TIMER_STATE_IDLE, TIMER_STATE_TICKING } |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
static void | ack_ticks (struct pthread_timer *timer, unsigned int num) |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
static int | check_timer (struct pthread_timer *timer) |
static void * | do_timing (void *arg) |
static int | init_timing_thread (void) |
static int | load_module (void) |
static int | pthread_timer_ack (void *data, unsigned int quantity) |
static void | pthread_timer_close (void *data) |
static int | pthread_timer_cmp (void *obj, void *arg, int flags) |
static void | pthread_timer_destructor (void *obj) |
static int | pthread_timer_disable_continuous (void *data) |
static int | pthread_timer_enable_continuous (void *data) |
static int | pthread_timer_fd (void *data) |
static enum ast_timer_event | pthread_timer_get_event (void *data) |
static unsigned int | pthread_timer_get_max_rate (void *data) |
static int | pthread_timer_hash (const void *obj, const int flags) |
static void * | pthread_timer_open (void) |
static int | pthread_timer_set_rate (void *data, unsigned int rate) |
static int | run_timer (void *obj, void *arg, int flags) |
static void | signal_pipe (struct pthread_timer *timer) |
static int | unload_module (void) |
static void | unsignal_pipe (struct pthread_timer *timer) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "pthread Timing Interface" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_EXTENDED, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_TIMING, } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static struct ao2_container * | pthread_timers |
static struct ast_timing_interface | pthread_timing |
static void * | timing_funcs_handle |
struct { | |
ast_cond_t cond | |
ast_mutex_t lock | |
unsigned int stop:1 | |
pthread_t thread | |
} | timing_thread |
Data for the timing thread. More... | |
pthread timing interface
Definition in file res_timing_pthread.c.
#define MAX_RATE 100 |
Definition at line 71 of file res_timing_pthread.c.
Referenced by pthread_timer_get_max_rate(), and pthread_timer_set_rate().
#define PTHREAD_TIMER_BUCKETS 563 |
Definition at line 74 of file res_timing_pthread.c.
Referenced by load_module().
anonymous enum |
Enumerator | |
---|---|
PIPE_READ | |
PIPE_WRITE |
Definition at line 76 of file res_timing_pthread.c.
enum pthread_timer_state |
Enumerator | |
---|---|
TIMER_STATE_IDLE | |
TIMER_STATE_TICKING |
Definition at line 81 of file res_timing_pthread.c.
|
static |
Definition at line 476 of file res_timing_pthread.c.
|
static |
Definition at line 476 of file res_timing_pthread.c.
|
static |
Definition at line 312 of file res_timing_pthread.c.
References ast_assert, pthread_timer::continuous, pthread_timer::pending_ticks, and unsignal_pipe().
Referenced by pthread_timer_ack().
struct ast_module* AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 476 of file res_timing_pthread.c.
|
static |
0 | no timer tick needed |
non-zero | write to the timing pipe needed |
Definition at line 286 of file res_timing_pthread.c.
References ast_tvdiff_ms(), ast_tvnow(), pthread_timer::interval, pthread_timer::start, pthread_timer::state, pthread_timer::tick_count, and TIMER_STATE_IDLE.
Referenced by run_timer().
|
static |
Definition at line 395 of file res_timing_pthread.c.
References ao2_callback, ao2_container_count(), ast_cond_timedwait, ast_cond_wait, ast_mutex_lock, ast_mutex_unlock, ast_tv(), ast_tvadd(), ast_tvnow(), NULL, OBJ_NODATA, run_timer(), and timing_thread.
Referenced by init_timing_thread().
|
static |
Definition at line 423 of file res_timing_pthread.c.
References ast_cond_init, ast_log, ast_mutex_init, ast_pthread_create_background, do_timing(), LOG_ERROR, NULL, and timing_thread.
Referenced by load_module().
|
static |
Definition at line 436 of file res_timing_pthread.c.
References AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_hash, ao2_ref, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_register_timing_interface, init_timing_thread(), NULL, PTHREAD_TIMER_BUCKETS, pthread_timer_cmp(), pthread_timer_hash(), and timing_funcs_handle.
Referenced by unload_module().
|
static |
Definition at line 180 of file res_timing_pthread.c.
References ack_ticks(), ao2_lock, ao2_unlock, ast_assert, and timer.
|
static |
Definition at line 143 of file res_timing_pthread.c.
References ao2_ref, ao2_unlink, and timer.
|
static |
Definition at line 275 of file res_timing_pthread.c.
References CMP_MATCH, CMP_STOP, pthread_timer::pipe, and PIPE_READ.
Referenced by load_module().
|
static |
Definition at line 247 of file res_timing_pthread.c.
References pthread_timer::pipe, PIPE_READ, PIPE_WRITE, and timer.
Referenced by pthread_timer_open().
|
static |
Definition at line 207 of file res_timing_pthread.c.
References ao2_lock, ao2_unlock, pthread_timer::continuous, timer, and unsignal_pipe().
|
static |
Definition at line 193 of file res_timing_pthread.c.
References ao2_lock, ao2_unlock, pthread_timer::continuous, signal_pipe(), and timer.
|
static |
Definition at line 240 of file res_timing_pthread.c.
References pthread_timer::pipe, PIPE_READ, and timer.
|
static |
Definition at line 221 of file res_timing_pthread.c.
References ao2_lock, ao2_unlock, AST_TIMING_EVENT_CONTINUOUS, AST_TIMING_EVENT_EXPIRED, pthread_timer::continuous, and timer.
|
static |
Definition at line 235 of file res_timing_pthread.c.
References MAX_RATE.
|
static |
Definition at line 265 of file res_timing_pthread.c.
References pthread_timer::pipe, PIPE_READ, and timer.
Referenced by load_module().
|
static |
Definition at line 114 of file res_timing_pthread.c.
References ao2_alloc, ao2_container_count(), ao2_link_flags, ao2_lock, ao2_ref, ao2_unlock, ast_cond_signal, ast_mutex_lock, ast_mutex_unlock, ast_pipe_nonblock, errno, NULL, OBJ_NOLOCK, pthread_timer::pipe, PIPE_READ, PIPE_WRITE, pthread_timer_destructor(), pthread_timer::state, timer, TIMER_STATE_IDLE, and timing_thread.
|
static |
Definition at line 151 of file res_timing_pthread.c.
References ao2_lock, ao2_unlock, ast_log, ast_tv(), ast_tvnow(), errno, pthread_timer::interval, LOG_ERROR, MAX_RATE, pthread_timer::rate, roundf(), pthread_timer::start, pthread_timer::state, pthread_timer::tick_count, timer, TIMER_STATE_IDLE, and TIMER_STATE_TICKING.
|
static |
Definition at line 377 of file res_timing_pthread.c.
References ao2_lock, ao2_unlock, check_timer(), pthread_timer::pending_ticks, signal_pipe(), pthread_timer::state, timer, and TIMER_STATE_IDLE.
Referenced by do_timing().
|
static |
Definition at line 337 of file res_timing_pthread.c.
References ast_log, errno, LOG_ERROR, pthread_timer::pipe, pthread_timer::pipe_signaled, and PIPE_WRITE.
Referenced by pthread_timer_enable_continuous(), and run_timer().
|
static |
Definition at line 454 of file res_timing_pthread.c.
References ao2_ref, ast_cond_signal, AST_MODFLAG_LOAD_ORDER, AST_MODPRI_TIMING, AST_MODULE_INFO(), AST_MODULE_SUPPORT_EXTENDED, ast_mutex_lock, ast_mutex_unlock, ast_unregister_timing_interface(), ASTERISK_GPL_KEY, load_module(), NULL, timing_funcs_handle, and timing_thread.
|
static |
Definition at line 359 of file res_timing_pthread.c.
References ast_log, errno, LOG_ERROR, pthread_timer::pipe, PIPE_READ, and pthread_timer::pipe_signaled.
Referenced by ack_ticks(), and pthread_timer_disable_continuous().
|
static |
Definition at line 476 of file res_timing_pthread.c.
|
static |
Definition at line 476 of file res_timing_pthread.c.
ast_cond_t cond |
Definition at line 110 of file res_timing_pthread.c.
ast_mutex_t lock |
Definition at line 109 of file res_timing_pthread.c.
|
static |
Definition at line 73 of file res_timing_pthread.c.
|
static |
Definition at line 56 of file res_timing_pthread.c.
unsigned int stop |
Definition at line 111 of file res_timing_pthread.c.
pthread_t thread |
Definition at line 108 of file res_timing_pthread.c.
|
static |
Definition at line 44 of file res_timing_pthread.c.
Referenced by load_module(), and unload_module().
struct { ... } timing_thread |
Data for the timing thread.
Referenced by do_timing(), init_timing_thread(), pthread_timer_open(), and unload_module().