RTS API Documentation  1.10.11
switch_scheduler.h
Go to the documentation of this file.
1 /*
2  * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
3  * Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
4  *
5  * Version: MPL 1.1
6  *
7  * The contents of this file are subject to the Mozilla Public License Version
8  * 1.1 (the "License"); you may not use this file except in compliance with
9  * the License. You may obtain a copy of the License at
10  * http://www.mozilla.org/MPL/
11  *
12  * Software distributed under the License is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14  * for the specific language governing rights and limitations under the
15  * License.
16  *
17  * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
18  *
19  * The Initial Developer of the Original Code is
20  * Anthony Minessale II <anthm@freeswitch.org>
21  * Portions created by the Initial Developer are Copyright (C)
22  * the Initial Developer. All Rights Reserved.
23  *
24  * Contributor(s):
25  *
26  * Anthony Minessale II <anthm@freeswitch.org>
27  *
28  *
29  * switch_scheduler.h -- Scheduler Engine
30  *
31  */
32 
33 #ifndef SWITCH_SCHEDULER_H
34 #define SWITCH_SCHEDULER_H
35 
36 #include <switch.h>
37 
39 ///\defgroup sched1 Scheduler
40 ///\ingroup core1
41 ///\{
43  int64_t created;
44  int64_t runtime;
45  uint32_t cmd_id;
46  uint32_t repeat;
47  char *group;
48  void *cmd_arg;
49  uint32_t task_id;
50  unsigned long hash;
51 };
52 
53 
54 /*!
55  \brief Schedule a task in the future
56  \param task_runtime the time in epoch seconds to execute the task.
57  \param func the callback function to execute when the task is executed.
58  \param desc an arbitrary description of the task.
59  \param group a group id tag to link multiple tasks to a single entity.
60  \param cmd_id an arbitrary index number be used in the callback.
61  \param cmd_arg user data to be passed to the callback.
62  \param flags flags to alter behaviour
63  \return the id of the task
64 */
65 SWITCH_DECLARE(uint32_t) switch_scheduler_add_task(time_t task_runtime,
67  const char *desc, const char *group, uint32_t cmd_id, void *cmd_arg, switch_scheduler_flag_t flags);
68 
69 /*!
70  \brief Schedule a task in the future
71  \param task_runtime the time in epoch seconds to execute the task.
72  \param func the callback function to execute when the task is executed.
73  \param desc an arbitrary description of the task.
74  \param group a group id tag to link multiple tasks to a single entity.
75  \param cmd_id an arbitrary index number be used in the callback.
76  \param cmd_arg user data to be passed to the callback.
77  \param flags flags to alter behaviour
78  \param task_id pointer to put the id of the task to
79  \return the id of the task
80 */
81 
82 SWITCH_DECLARE(uint32_t) switch_scheduler_add_task_ex(time_t task_runtime,
84  const char *desc, const char *group, uint32_t cmd_id, void *cmd_arg, switch_scheduler_flag_t flags, uint32_t *task_id);
85 
86 /*!
87  \brief Delete a scheduled task
88  \param task_id the id of the task
89  \return the number of jobs deleted
90 */
92 
93 /*!
94  \brief Delete a scheduled task based on the group name
95  \param group the group name
96  \return the number of jobs deleted
97 */
99 
100 
101 /*!
102  \brief Start the scheduler system
103 */
105 
106 /*!
107  \brief Stop the scheduler system
108 */
110 
111 ///\}
112 
114 #endif
115 /* For Emacs:
116  * Local Variables:
117  * mode:c
118  * indent-tabs-mode:t
119  * tab-width:4
120  * c-basic-offset:4
121  * End:
122  * For VIM:
123  * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
124  */
uint32_t switch_scheduler_del_task_group(const char *group)
Delete a scheduled task based on the group name.
#define SWITCH_END_EXTERN_C
Definition: switch.h:43
void switch_scheduler_task_thread_start(void)
Start the scheduler system.
void switch_scheduler_task_thread_stop(void)
Stop the scheduler system.
uint32_t switch_scheduler_flag_t
Definition: switch_types.h:493
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.
uint32_t switch_scheduler_del_task_id(uint32_t task_id)
Delete a scheduled task.
uint32_t switch_scheduler_add_task_ex(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, uint32_t *task_id)
Schedule a task in the future.
void(* switch_scheduler_func_t)(switch_scheduler_task_t *task)
Main Library Header.
#define SWITCH_DECLARE(type)
#define SWITCH_BEGIN_EXTERN_C
Definition: switch.h:42