diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-08-17 14:07:44 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-08-17 14:07:44 +0000 |
commit | d023eb5b7016453a9da77f9d6fc918ef39f56c0e (patch) | |
tree | 3a369ca76d3642f3c500f34c1d98755f66f54200 /include/asterisk | |
parent | 81cd3d2c34bdb8ce420c2d5425d5cf822b0fb730 (diff) |
This commit adds a scheduler API call, ast_sched_replace that can be used
in place of a very common construct. I also used it in a number of places
in chan_sip.
if (id > -1)
ast_sched_del(sched, id);
id = ast_sched_add(sched, ...);
changes to:
ast_sched_replace(id, sched, ...);
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@79861 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include/asterisk')
-rw-r--r-- | include/asterisk/sched.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/include/asterisk/sched.h b/include/asterisk/sched.h index 00dc7a0a2..5238ecab5 100644 --- a/include/asterisk/sched.h +++ b/include/asterisk/sched.h @@ -71,6 +71,18 @@ typedef int (*ast_sched_cb)(void *data); */ int ast_sched_add(struct sched_context *con, int when, ast_sched_cb callback, void *data); +/*! + * \brief replace a scheduler entry + * + * This deletes the scheduler entry for old_id if it exists, and then + * calls ast_sched_add to create a new entry. A negative old_id will + * be ignored. + * + * \retval -1 failure + * \retval otherwise, returns scheduled item ID + */ +int ast_sched_replace(int old_id, struct sched_context *con, int when, ast_sched_cb callback, void *data); + /*!Adds a scheduled event with rescheduling support * \param con Scheduler context to add * \param when how many milliseconds to wait for event to occur @@ -86,6 +98,18 @@ int ast_sched_add(struct sched_context *con, int when, ast_sched_cb callback, vo */ int ast_sched_add_variable(struct sched_context *con, int when, ast_sched_cb callback, void *data, int variable); +/*! + * \brief replace a scheduler entry + * + * This deletes the scheduler entry for old_id if it exists, and then + * calls ast_sched_add to create a new entry. A negative old_id will + * be ignored. + * + * \retval -1 failure + * \retval otherwise, returns scheduled item ID + */ +int ast_sched_replace_variable(int old_id, struct sched_context *con, int when, ast_sched_cb callback, void *data, int variable); + /*! \brief Deletes a scheduled event * Remove this event from being run. A procedure should not remove its * own event, but return 0 instead. |