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.
|
#define | MAX_RATE 100 |
|
#define | PTHREAD_TIMER_BUCKETS 563 |
|
|
enum | { PIPE_READ = 0,
PIPE_WRITE = 1
} |
|
enum | pthread_timer_state { TIMER_STATE_IDLE,
TIMER_STATE_TICKING
} |
|
|
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) |
|
|
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.
|
|
pthread timing interface
- Author
- Russell Bryant russe.nosp@m.ll@d.nosp@m.igium.nosp@m..com
Definition in file res_timing_pthread.c.
- Return values
-
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(), and pthread_timer::interval.
290 if (timer->state == TIMER_STATE_IDLE) {
298 if (!timer->tick_count) {
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
static int pthread_timer_cmp |
( |
void * |
obj, |
|
|
void * |
arg, |
|
|
int |
flags |
|
) |
| |
|
static |
static int pthread_timer_hash |
( |
const void * |
obj, |
|
|
const int |
flags |
|
) |
| |
|
static |
- Note
- only PIPE_READ is guaranteed valid
Definition at line 265 of file res_timing_pthread.c.
269 return timer->pipe[PIPE_READ];