138 for (tp =
globals.task_list; tp;) {
181 globals.task_thread_running = 1;
184 while (
globals.task_thread_running == 1) {
203 globals.task_thread_running = 0;
221 if (task_runtime < now) {
222 container->
task.
repeat = (uint32_t)task_runtime;
226 container->
func = func;
229 container->
task.
group = strdup(group ? group :
"none");
232 container->
flags = flags;
233 container->
desc = strdup(desc ? desc :
"none");
239 tp->
next = container;
298 unsigned long hash = 0;
344 if (
globals.task_thread_running == 1) {
348 globals.task_thread_running = -1;
352 while (
globals.task_thread_running) {
struct apr_queue_t switch_queue_t
#define switch_event_fire(event)
Fire an event filling in most of the arguements with obvious values.
#define switch_core_new_memory_pool(p)
Create a new sub memory pool from the core's master pool.
uint32_t switch_scheduler_del_task_group(const char *group)
Delete a scheduled task based on the group name.
#define SWITCH_CHANNEL_LOG
switch_scheduler_func_t func
static void *SWITCH_THREAD_FUNC task_own_thread(switch_thread_t *thread, void *obj)
static void switch_scheduler_execute(switch_scheduler_task_container_t *tp)
switch_status_t switch_queue_pop_timeout(switch_queue_t *queue, void **data, switch_interval_time_t timeout)
void switch_scheduler_task_thread_start(void)
Start the scheduler system.
#define switch_core_destroy_memory_pool(p)
Returns a subpool back to the main pool.
switch_memory_pool_t * pool
switch_status_t switch_event_add_header(switch_event_t *event, switch_stack_t stack, const char *header_name, const char *fmt,...) PRINTF_FUNCTION(4
Add a header to an event.
Representation of an event.
switch_status_t switch_queue_trypop(switch_queue_t *queue, void **data)
unsigned int switch_ci_hashfunc_default(const char *char_key, switch_ssize_t *klen)
void switch_scheduler_task_thread_stop(void)
Stop the scheduler system.
uint32_t switch_scheduler_flag_t
static switch_thread_t * thread
uint32_t switch_scheduler_add_task(time_t task_runtime, switch_scheduler_func_t func, const char *desc, const char *group, uint32_t cmd_id, void *cmd_arg, switch_scheduler_flag_t flags)
Schedule a task in the future.
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
switch_status_t switch_thread_join(switch_status_t *retval, switch_thread_t *thd)
#define SWITCH_MUTEX_NESTED
switch_status_t switch_threadattr_detach_set(switch_threadattr_t *attr, int32_t on)
#define switch_yield(ms)
Wait a desired number of microseconds and yield the CPU.
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
uint32_t switch_scheduler_del_task_id(uint32_t task_id)
Delete a scheduled task.
switch_status_t switch_event_add_header_string(switch_event_t *event, switch_stack_t stack, const char *header_name, const char *data)
Add a string header to an event.
#define switch_zmalloc(ptr, len)
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
switch_status_t switch_mutex_init(switch_mutex_t **lock, unsigned int flags, switch_memory_pool_t *pool)
switch_memory_pool_t * memory_pool
void(* switch_scheduler_func_t)(switch_scheduler_task_t *task)
#define switch_str_nil(s)
Make a null string a blank string instead.
struct switch_scheduler_task_container * next
switch_thread_t * task_thread_p
struct apr_thread_mutex_t switch_mutex_t
switch_status_t
Common return values.
#define SWITCH_INT64_T_FMT
switch_queue_t * event_queue
struct apr_thread_t switch_thread_t
#define switch_event_create(event, id)
Create a new event assuming it will not be custom event and therefore hiding the unused parameters...
static void *SWITCH_THREAD_FUNC switch_scheduler_task_thread(switch_thread_t *thread, void *obj)
time_t switch_epoch_time_now(time_t *t)
Get the current epoch time.
switch_status_t switch_queue_push(switch_queue_t *queue, void *data)
struct apr_pool_t switch_memory_pool_t
#define switch_test_flag(obj, flag)
Test for the existance of a flag on an arbitary object.
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
switch_status_t switch_threadattr_create(switch_threadattr_t **new_attr, switch_memory_pool_t *pool)
switch_status_t switch_thread_create(switch_thread_t **new_thread, switch_threadattr_t *attr, switch_thread_start_t func, void *data, switch_memory_pool_t *cont)
switch_memory_pool_t * pool
switch_status_t switch_queue_create(switch_queue_t **queue, unsigned int queue_capacity, switch_memory_pool_t *pool)
void switch_event_destroy(switch_event_t **event)
Destroy an event.
static int task_thread_loop(int done)
switch_mutex_t * task_mutex
switch_scheduler_task_container_t * task_list
switch_scheduler_task_t task