FreeSWITCH API Documentation  1.7.0
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 Delete a scheduled task
71  \param task_id the id of the task
72  \return the number of jobs deleted
73 */
75 
76 /*!
77  \brief Delete a scheduled task based on the group name
78  \param group the group name
79  \return the number of jobs deleted
80 */
81 SWITCH_DECLARE(uint32_t) switch_scheduler_del_task_group(const char *group);
82 
83 
84 /*!
85  \brief Start the scheduler system
86 */
88 
89 /*!
90  \brief Stop the scheduler system
91 */
93 
94 ///\}
95 
97 #endif
98 /* For Emacs:
99  * Local Variables:
100  * mode:c
101  * indent-tabs-mode:t
102  * tab-width:4
103  * c-basic-offset:4
104  * End:
105  * For VIM:
106  * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
107  */
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:461
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.
void(* switch_scheduler_func_t)(switch_scheduler_task_t *task)
Main Library Header.
#define SWITCH_DECLARE(type)
uint32_t task_id
#define SWITCH_BEGIN_EXTERN_C
Definition: switch.h:42