summaryrefslogtreecommitdiff
path: root/include/asterisk/sched.h
diff options
context:
space:
mode:
authorTilghman Lesher <tilghman@meg.abyt.es>2008-01-27 23:14:48 +0000
committerTilghman Lesher <tilghman@meg.abyt.es>2008-01-27 23:14:48 +0000
commit69ade72e3cc397142036db1e71d49c94daa2d43c (patch)
treefe8d41968e18de37ca1f6a42b55f4075ed2cfe51 /include/asterisk/sched.h
parentac699196f54f4a4659b605c02cfdac6c23d7d971 (diff)
With the switch to the ast_sched_replace* API in trunk, we lose the correction
that was just merged from 1.4, so this is a changeover to those APIs to use the macro versions, so that we properly detect errors from ast_sched_del, instead of simply ignoring the return values. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@100497 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include/asterisk/sched.h')
-rw-r--r--include/asterisk/sched.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/asterisk/sched.h b/include/asterisk/sched.h
index dbe066310..febcbce94 100644
--- a/include/asterisk/sched.h
+++ b/include/asterisk/sched.h
@@ -45,6 +45,19 @@ extern "C" {
id = -1; \
} while (0);
+#define AST_SCHED_REPLACE_VARIABLE(id, sched, when, callback, data, variable) \
+ do { \
+ int _count = 0; \
+ while (id > -1 && ast_sched_del(sched, id) && _count++ < 10) \
+ usleep(1); \
+ if (_count == 10) \
+ ast_log(LOG_WARNING, "Unable to cancel schedule ID %d. This is probably a bug (%s: %s, line %d).\n", id, __FILE__, __PRETTY_FUNCTION__, __LINE__); \
+ id = ast_sched_add_variable(sched, when, callback, data, variable); \
+ } while (0);
+
+#define AST_SCHED_REPLACE(id, sched, when, callback, data) \
+ AST_SCHED_REPLACE_VARIABLE(id, sched, when, callback, data, 0)
+
struct sched_context;
/*! \brief New schedule context