Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2664
Modified Files: Tag: devel_0_38 m_sched.c Log Message: additional return value for callbacks
Index: m_sched.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/m_sched.c,v retrieving revision 1.5.4.14 retrieving revision 1.5.4.15 diff -C2 -d -r1.5.4.14 -r1.5.4.15 *** m_sched.c 15 Jan 2005 22:56:25 -0000 1.5.4.14 --- m_sched.c 16 Jan 2005 16:07:45 -0000 1.5.4.15 *************** *** 659,675 **** do { ! if ( ((idle_callback->function)(idle_callback->argv)) == 0) { freebytes (idle_callback->argv, idle_callback->argc); freebytes ((void*)idle_callback, sizeof(t_sched_callback)); ! } ! idle_callback = fifo_get(callback_fifo);
! remain = stop-sys_getrealtime(); } ! while ((remain > 0) && (idle_callback != NULL));
/* sleep for the rest of the time */ ! // if(remain > 0) sys_microsleep(remain); return 0; } --- 659,688 ---- do { ! int status = (idle_callback->function)(idle_callback->argv); ! remain = stop-sys_getrealtime(); ! ! switch (status) { + /* callbacks returning 0 will be deleted + * beware: if a callback never returns zero, it will run until the end of time, + * blocking other callbacks */ + case 0: freebytes (idle_callback->argv, idle_callback->argc); freebytes ((void*)idle_callback, sizeof(t_sched_callback)); ! idle_callback = fifo_get(callback_fifo);
! /* callbacks returning 1 will be run again */ ! case 1: ! break; ! ! /* callbacks returning 2 will be run during the next idle callback */ ! case 2: ! return 0; ! } } ! while ((idle_callback != NULL) && (remain > 0));
/* sleep for the rest of the time */ ! if(remain > 100) sys_microsleep(remain); return 0; }