summaryrefslogtreecommitdiff
path: root/main/sched.c
diff options
context:
space:
mode:
authorRussell Bryant <russell@russellbryant.com>2007-08-17 14:07:44 +0000
committerRussell Bryant <russell@russellbryant.com>2007-08-17 14:07:44 +0000
commitf5bf66bcd75d243dd4708197fb4d149e8dc4cc27 (patch)
tree3a369ca76d3642f3c500f34c1d98755f66f54200 /main/sched.c
parentc78ddffb047767ecdffccbd0a426f3ca91722c24 (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: https://origsvn.digium.com/svn/asterisk/trunk@79861 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/sched.c')
-rw-r--r--main/sched.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/main/sched.c b/main/sched.c
index 1a07ab659..602c8516e 100644
--- a/main/sched.c
+++ b/main/sched.c
@@ -207,6 +207,12 @@ static int sched_settime(struct timeval *tv, int when)
return 0;
}
+int ast_sched_replace_variable(int old_id, struct sched_context *con, int when, ast_sched_cb callback, void *data, int variable)
+{
+ if (old_id > -1)
+ ast_sched_del(con, old_id);
+ return ast_sched_add_variable(con, when, callback, data, variable);
+}
/*! \brief
* Schedule callback(data) to happen when ms into the future
@@ -244,6 +250,13 @@ int ast_sched_add_variable(struct sched_context *con, int when, ast_sched_cb cal
return res;
}
+int ast_sched_replace(int old_id, struct sched_context *con, int when, ast_sched_cb callback, void *data)
+{
+ if (old_id > -1)
+ ast_sched_del(con, old_id);
+ return ast_sched_add(con, when, callback, data);
+}
+
int ast_sched_add(struct sched_context *con, int when, ast_sched_cb callback, void *data)
{
return ast_sched_add_variable(con, when, callback, data, 0);