|
|
@ -27,9 +27,8 @@
|
|
|
|
extern "C" {
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/*! Max num of schedule structs */
|
|
|
|
/*! \brief Max num of schedule structs
|
|
|
|
/*!
|
|
|
|
* \note The max number of schedule structs to keep around
|
|
|
|
* The max number of schedule structs to keep around
|
|
|
|
|
|
|
|
* for use. Undefine to disable schedule structure
|
|
|
|
* for use. Undefine to disable schedule structure
|
|
|
|
* caching. (Only disable this on very low memory
|
|
|
|
* caching. (Only disable this on very low memory
|
|
|
|
* machines)
|
|
|
|
* machines)
|
|
|
@ -38,111 +37,104 @@ extern "C" {
|
|
|
|
|
|
|
|
|
|
|
|
struct sched_context;
|
|
|
|
struct sched_context;
|
|
|
|
|
|
|
|
|
|
|
|
/*! New schedule context */
|
|
|
|
/*! \brief New schedule context
|
|
|
|
/* !
|
|
|
|
* \note Create a scheduling context
|
|
|
|
* Create a scheduling context
|
|
|
|
* \return Returns a malloc'd sched_context structure, NULL on failure
|
|
|
|
* Returns a malloc'd sched_context structure, NULL on failure
|
|
|
|
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
extern struct sched_context *sched_context_create(void);
|
|
|
|
extern struct sched_context *sched_context_create(void);
|
|
|
|
|
|
|
|
|
|
|
|
/*! destroys a schedule context */
|
|
|
|
/*! \brief destroys a schedule context
|
|
|
|
/*!
|
|
|
|
|
|
|
|
* \param c Context to free
|
|
|
|
|
|
|
|
* Destroys (free's) the given sched_context structure
|
|
|
|
* Destroys (free's) the given sched_context structure
|
|
|
|
* Returns 0 on success, -1 on failure
|
|
|
|
* \param c Context to free
|
|
|
|
|
|
|
|
* \return Returns 0 on success, -1 on failure
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
void sched_context_destroy(struct sched_context *c);
|
|
|
|
void sched_context_destroy(struct sched_context *c);
|
|
|
|
|
|
|
|
|
|
|
|
/*! callback for a cheops scheduler */
|
|
|
|
/*! \brief callback for a cheops scheduler
|
|
|
|
/*!
|
|
|
|
|
|
|
|
* A cheops scheduler callback takes a pointer with callback data and
|
|
|
|
* A cheops scheduler callback takes a pointer with callback data and
|
|
|
|
* returns a 0 if it should not be run again, or non-zero if it should be
|
|
|
|
* \return returns a 0 if it should not be run again, or non-zero if it should be
|
|
|
|
* rescheduled to run again
|
|
|
|
* rescheduled to run again
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
typedef int (*ast_sched_cb)(void *data);
|
|
|
|
typedef int (*ast_sched_cb)(void *data);
|
|
|
|
#define AST_SCHED_CB(a) ((ast_sched_cb)(a))
|
|
|
|
#define AST_SCHED_CB(a) ((ast_sched_cb)(a))
|
|
|
|
|
|
|
|
|
|
|
|
/*!Adds a scheduled event */
|
|
|
|
/*! \brief Adds a scheduled event
|
|
|
|
/*!
|
|
|
|
|
|
|
|
* \param con Schduler context to add
|
|
|
|
|
|
|
|
* \param when how many milliseconds to wait for event to occur
|
|
|
|
|
|
|
|
* \param callback function to call when the amount of time expires
|
|
|
|
|
|
|
|
* \param data data to pass to the callback
|
|
|
|
|
|
|
|
* Schedule an event to take place at some point in the future. callback
|
|
|
|
* Schedule an event to take place at some point in the future. callback
|
|
|
|
* will be called with data as the argument, when milliseconds into the
|
|
|
|
* will be called with data as the argument, when milliseconds into the
|
|
|
|
* future (approximately)
|
|
|
|
* future (approximately)
|
|
|
|
* If callback returns 0, no further events will be re-scheduled
|
|
|
|
* If callback returns 0, no further events will be re-scheduled
|
|
|
|
* Returns a schedule item ID on success, -1 on failure
|
|
|
|
* \param con Scheduler context to add
|
|
|
|
|
|
|
|
* \param when how many milliseconds to wait for event to occur
|
|
|
|
|
|
|
|
* \param callback function to call when the amount of time expires
|
|
|
|
|
|
|
|
* \param data data to pass to the callback
|
|
|
|
|
|
|
|
* \return Returns a schedule item ID on success, -1 on failure
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
extern int ast_sched_add(struct sched_context *con, int when, ast_sched_cb callback, void *data);
|
|
|
|
extern int ast_sched_add(struct sched_context *con, int when, ast_sched_cb callback, void *data);
|
|
|
|
|
|
|
|
|
|
|
|
/*!Adds a scheduled event */
|
|
|
|
/*!Adds a scheduled event with rescheduling support
|
|
|
|
/*!
|
|
|
|
* \param con Scehduler context to add
|
|
|
|
* \param con Schduler context to add
|
|
|
|
|
|
|
|
* \param when how many milliseconds to wait for event to occur
|
|
|
|
* \param when how many milliseconds to wait for event to occur
|
|
|
|
* \param callback function to call when the amount of time expires
|
|
|
|
* \param callback function to call when the amount of time expires
|
|
|
|
* \param data data to pass to the callback
|
|
|
|
* \param data data to pass to the callback
|
|
|
|
* \param variable If true, the result value of callback function will be
|
|
|
|
* \param variable If true, the result value of callback function will be
|
|
|
|
* used for rescheduling
|
|
|
|
* used for rescheduling
|
|
|
|
* Schedule an event to take place at some point in the future. callback
|
|
|
|
* Schedule an event to take place at some point in the future. Callback
|
|
|
|
* will be called with data as the argument, when milliseconds into the
|
|
|
|
* will be called with data as the argument, when milliseconds into the
|
|
|
|
* future (approximately)
|
|
|
|
* future (approximately)
|
|
|
|
* If callback returns 0, no further events will be re-scheduled
|
|
|
|
* If callback returns 0, no further events will be re-scheduled
|
|
|
|
* Returns a schedule item ID on success, -1 on failure
|
|
|
|
* \return Returns a schedule item ID on success, -1 on failure
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
extern int ast_sched_add_variable(struct sched_context *con, int when, ast_sched_cb callback, void *data, int variable);
|
|
|
|
extern int ast_sched_add_variable(struct sched_context *con, int when, ast_sched_cb callback, void *data, int variable);
|
|
|
|
|
|
|
|
|
|
|
|
/*! Deletes a scheduled event */
|
|
|
|
/*! \brief Deletes a scheduled event
|
|
|
|
/*!
|
|
|
|
|
|
|
|
* \param con scheduling context to delete item from
|
|
|
|
|
|
|
|
* \param id ID of the scheduled item to delete
|
|
|
|
|
|
|
|
* Remove this event from being run. A procedure should not remove its
|
|
|
|
* Remove this event from being run. A procedure should not remove its
|
|
|
|
* own event, but return 0 instead.
|
|
|
|
* own event, but return 0 instead.
|
|
|
|
* Returns 0 on success, -1 on failure
|
|
|
|
* \param con scheduling context to delete item from
|
|
|
|
|
|
|
|
* \param id ID of the scheduled item to delete
|
|
|
|
|
|
|
|
* \return Returns 0 on success, -1 on failure
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
extern int ast_sched_del(struct sched_context *con, int id);
|
|
|
|
extern int ast_sched_del(struct sched_context *con, int id);
|
|
|
|
|
|
|
|
|
|
|
|
/*! Determines number of seconds until the next outstanding event to take place */
|
|
|
|
/*! \brief Determines number of seconds until the next outstanding event to take place
|
|
|
|
/*!
|
|
|
|
|
|
|
|
* \param con context to act upon
|
|
|
|
|
|
|
|
* Determine the number of seconds until the next outstanding event
|
|
|
|
* Determine the number of seconds until the next outstanding event
|
|
|
|
* should take place, and return the number of milliseconds until
|
|
|
|
* should take place, and return the number of milliseconds until
|
|
|
|
* it needs to be run. This value is perfect for passing to the poll
|
|
|
|
* it needs to be run. This value is perfect for passing to the poll
|
|
|
|
* call. Returns "-1" if there is nothing there are no scheduled events
|
|
|
|
* call.
|
|
|
|
|
|
|
|
* \param con context to act upon
|
|
|
|
|
|
|
|
* \return Returns "-1" if there is nothing there are no scheduled events
|
|
|
|
* (and thus the poll should not timeout)
|
|
|
|
* (and thus the poll should not timeout)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
extern int ast_sched_wait(struct sched_context *con);
|
|
|
|
extern int ast_sched_wait(struct sched_context *con);
|
|
|
|
|
|
|
|
|
|
|
|
/*! Runs the queue */
|
|
|
|
/*! \brief Runs the queue
|
|
|
|
/*!
|
|
|
|
|
|
|
|
* \param con Scheduling context to run
|
|
|
|
* \param con Scheduling context to run
|
|
|
|
* Run the queue, executing all callbacks which need to be performed
|
|
|
|
* Run the queue, executing all callbacks which need to be performed
|
|
|
|
* at this time. Returns the number of events processed.
|
|
|
|
* at this time.
|
|
|
|
|
|
|
|
* \param con context to act upon
|
|
|
|
|
|
|
|
* \return Returns the number of events processed.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
extern int ast_sched_runq(struct sched_context *con);
|
|
|
|
extern int ast_sched_runq(struct sched_context *con);
|
|
|
|
|
|
|
|
|
|
|
|
/*!Dumps the scheduler contents */
|
|
|
|
/*! \brief Dumps the scheduler contents
|
|
|
|
/*!
|
|
|
|
|
|
|
|
* \param con Context to dump
|
|
|
|
|
|
|
|
* Debugging: Dump the contents of the scheduler to stderr
|
|
|
|
* Debugging: Dump the contents of the scheduler to stderr
|
|
|
|
|
|
|
|
* \param con Context to dump
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
extern void ast_sched_dump(const struct sched_context *con);
|
|
|
|
extern void ast_sched_dump(const struct sched_context *con);
|
|
|
|
|
|
|
|
|
|
|
|
/*!Returns the number of seconds before an event takes place */
|
|
|
|
/*! \brief Returns the number of seconds before an event takes place
|
|
|
|
/*!
|
|
|
|
|
|
|
|
* \param con Context to use
|
|
|
|
* \param con Context to use
|
|
|
|
* \param id Id to dump
|
|
|
|
* \param id Id to dump
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
extern long ast_sched_when(struct sched_context *con,int id);
|
|
|
|
extern long ast_sched_when(struct sched_context *con,int id);
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*!
|
|
|
|
*! Convenience macro for objects and reference (add)
|
|
|
|
* \brief Convenience macro for objects and reference (add)
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
#define ast_sched_add_object(obj,con,when,callback) ast_sched_add((con),(when),(callback), ASTOBJ_REF((obj)))
|
|
|
|
#define ast_sched_add_object(obj,con,when,callback) ast_sched_add((con),(when),(callback), ASTOBJ_REF((obj)))
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*!
|
|
|
|
*! Convenience macro for objects and reference (del)
|
|
|
|
* \brief Convenience macro for objects and reference (del)
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
#define ast_sched_del_object(obj,destructor,con,id) do { \
|
|
|
|
#define ast_sched_del_object(obj,destructor,con,id) do { \
|
|
|
|