aboutsummaryrefslogtreecommitdiff
path: root/pd/src/m_sched.c
diff options
context:
space:
mode:
authorMiller Puckette <millerpuckette@users.sourceforge.net>2004-11-06 16:07:34 +0000
committerMiller Puckette <millerpuckette@users.sourceforge.net>2004-11-06 16:07:34 +0000
commit981f641ef44fe4d72dcb0e1248a2f96ba53cee69 (patch)
treed5871a901628db17e12e6204d13b4bdb4b8a07d9 /pd/src/m_sched.c
parent5b0640e17d6db9e119d657fcadcf52ff317e704d (diff)
0.38 test 9 (mostly bug fixes)
svn path=/trunk/; revision=2226
Diffstat (limited to 'pd/src/m_sched.c')
-rw-r--r--pd/src/m_sched.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/pd/src/m_sched.c b/pd/src/m_sched.c
index b0854984..10c03473 100644
--- a/pd/src/m_sched.c
+++ b/pd/src/m_sched.c
@@ -382,6 +382,11 @@ the audio I/O system is still busy with previous transfers.
void sys_pollmidiqueue( void);
void sys_initmidiqueue( void);
+ /* 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);
+
int m_scheduler( void)
{
int idlecount = 0;
@@ -468,8 +473,13 @@ int m_scheduler( void)
/* T.Grill - enter idle phase -> unlock thread lock */
sys_unlock();
#endif
- if (timeforward != SENDDACS_SLEPT)
- sys_microsleep(sys_sleepgrain);
+ /* 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);
+ }
#ifdef THREAD_LOCKING
/* T.Grill - leave idle phase -> lock thread lock */
sys_lock();