diff options
Diffstat (limited to 'main/sched.c')
-rw-r--r-- | main/sched.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/main/sched.c b/main/sched.c index 34f8d5369..8fdbfed36 100644 --- a/main/sched.c +++ b/main/sched.c @@ -289,6 +289,26 @@ static void sched_release(struct ast_sched_context *con, struct sched *tmp) sched_free(tmp); } +void ast_sched_clean_by_callback(struct ast_sched_context *con, ast_sched_cb match, ast_sched_cb cleanup_cb) +{ + int i = 1; + struct sched *current; + + ast_mutex_lock(&con->lock); + while ((current = ast_heap_peek(con->sched_heap, i))) { + if (current->callback != match) { + i++; + continue; + } + + ast_heap_remove(con->sched_heap, current); + + cleanup_cb(current->data); + sched_release(con, current); + } + ast_mutex_unlock(&con->lock); +} + /*! \brief * Return the number of milliseconds * until the next scheduled event |