[PD-dev] sys_idlehook

Georg Holzmann grhPD at gmx.at
Wed Nov 9 23:51:20 CET 2005


Hallo devs!


In m_sched.c, line 383, there is the following declaration:


--------------8<---------8<----------
/* sys_idlehook is a hook the user can fill in to grab idle time.  Return
nonzero if you actually used the time; otherwise we're really really 
idle and
will now sleep. */
int (*sys_idlehook)(void);
-------8<------------8<--------------

which get's called in line 483:

--------8<---------8<--------------
/* call externally installed idle function if any. */
if (!sys_idlehook || !sys_idlehook())
{
   /* if even that had nothing to do, sleep. */
   if (timeforward != SENDDACS_SLEPT)
        sys_microsleep(sys_sleepgrain);
}
-----------8<--------------8<------


So, I'm not really sure, how to use this callback ...
If I write e.g. an external which uses this callback, how am I sure, 
that the specific function will be executed ?
Because in an other external, thread, or whatever, I could simply assign 
to that callback an other function !? because there is only a callback 
for one function ? (or am I thinking in a wrong direction ?)

(and I didn't find an example that uses this callback ... if there is 
one please let me know)


Thanks,
LG
Georg

PS: and yes I know there are the idle callbacks in devel which do 
exactly this - but how to do it in the current pd ?




More information about the Pd-dev mailing list