[PD-dev] sys_idlehook

Martin Peach martinrp at vax2.concordia.ca
Thu Nov 10 16:58:35 CET 2005


Tim Blechmann wrote:

>hi georg.
>
>  
>
>>--------------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<--------------
>>    
>>
>
>currently, miller's pd has the feature of using 1 (one) function
>pointer as idle hook. you can set it and it will get called.
>but if you want to use it, there is _no_ way to make sure, that this
>idle hook is not overridden by another function, nor if it will ever be
>called.
>it gives some functionality, but it's not reliable if you would want to
>work with it.
>it will work as long as you're the only one, who is using this hook,
>and you only set it in one thread.
>
>i doubt that anyone ever used it because of this and thus i removed it
>from devel.
>
>the only safe way to do thread synchronisation in miller's pd is using
>the sys_lock() ... but locks are bad, so don't use threads :-)
>
>cheers ... tim
>
>  
>
Surely if there were a procedure in place for using the idlehook, this 
could be made to work:
e.g. any external could check to see if idlehook was taken already. If 
so, copy the existing idlehook into its local space and replace the 
idlehook with its own. When the new idlehook is called, it should first 
call the old one and then its own before returning the 'or' of the two 
results.
On deallocating an idlehook, the external's deconstructor should replace 
the old idlehook. The last idlehook to be removed would be replaced with 
NULL.

Martin





More information about the Pd-dev mailing list