[Asterisk-Dev] scheduler

Martin Bangiev martin.bangiev at borsabg.com
Fri Apr 1 08:16:04 MST 2005


Ahaaa I found the solution!
I created additional thread that runs ast_sched_runq() in an infinitive 
loop (with some delay of-course).
It seems like the so called sched is actually only a queue or something 
like that.

Martin Bangiev wrote:

> Hi all,
> I'm trying to learn how to use the asterisk scheduler. For this 
> purpose I wrote a simple application based on app_skel.
> I added a global variable "static struct sched_context *sched;"
> I do initialize the sched variable during loading module
>
> int load_module(void) {
>        int res;
>        sched = sched_context_create();
>        res = ast_register_application(app, mysched_exec, synopsis, 
> descrip);
>        return res;
> }
>
> and I have a simple function that I want to be scheduled:
>
> static int test_sched(void *data) {
>        ast_log(LOG_NOTICE, "test_sched...\n");
>        return(0);
> }
>
> I add this function to the scheduler via a function called via extension
>
> static int mysched_exec(struct ast_channel *chan, void *data) {
>        LOCAL_USER_ADD(u);
>        ast_sched_add(sched, 1000, test_sched, NULL);
>        LOCAL_USER_REMOVE(u);
>        return(res);
> }
>
> According to the description I have to see "test_sched..." in my CLI 
> one second after the extension execute the mysched_exec function. But 
> it seems to me like the function doesn't start at all.
> Can someone tell me where am I wrong?
>
> Thank You in advance :)
> Martin
> _______________________________________________
> Asterisk-Dev mailing list
> Asterisk-Dev at lists.digium.com
> http://lists.digium.com/mailman/listinfo/asterisk-dev
> To UNSUBSCRIBE or update options visit:
>   http://lists.digium.com/mailman/listinfo/asterisk-dev
>
>




More information about the asterisk-dev mailing list