[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [sc-users] Pause a Routine (AppClock)
If you do ~f1.start, it will use the clock assigned to the task. By
default, this is TempoClock.default.
You can assign a clock to a task, and the task will always use that
clock if not told otherwise.
~f1 = Task({ ... }, AppClock);
Otherwise, you could .play the task and give AppClock as the argument
-- ~f1.play(AppClock).
Note that for Tasks, pause is a synonym of stop, and resume/start is a
synonym of play. The task remembers where it is even if you use
play/stop. (If you want the task to start over from the beginning,
it's necessary to .reset it explicitly.)
There is a potential disadvantage to running the GUI task 100% on
AppClock, and that is drift. Waiting 1.0 seconds in AppClock means the
next thing will happen 1.0 seconds *after the last yield*, not after
the last wakeup. So AppClock can get progressively later.
The more typical way to write gui stuff is:
~f1 = Task({
// do non-GUI stuff here
defer {
// do GUI stuff here
};
// more non-GUI stuff if you need it
// make sure your .wait or .yield is OUTSIDE the defer block
});
Now the Task can play on any clock (and overall timing is consistent),
but the GUI updates get pushed off to AppClock.
hjh
--
James Harkins /// dewdrop world
jamshark70@xxxxxxxxxxxxxxxxx
http://www.dewdrop-world.net
"Come said the Muse,
Sing me a song no poet has yet chanted,
Sing me the universal." -- Whitman
_______________________________________________
sc-users mailing list
info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/