Is this a bug?
// tasks, once stopped, can be resumed
t = TempoClock.new;
r = Task {
loop {
[thisThread.beats, thisThread.seconds].postln;
1.0.wait;
}
}.play(argClock: t, quant: 1);
r.stop;
t.stop;
t = TempoClock.new;
r.play(argClock: t, quant: 1);
r.stop;
// BUT a task,
// if it was transferred to a different clock
// before being stopped,
// can't be resumed anymore
t = TempoClock.new;
(
r = Task({
loop {
[thisThread.beats, thisThread.seconds].postln;
1.0.wait;
}
}).play(argClock: t, quant: 1);
)
// reschedule
(
u = TempoClock(t.tempo, t.beats.frac);
u.schedAbs(r.nextBeat + u.beats - t.beats, r);
t.stop;
)
// same sequence as initially --
// stop the task, then stop the clock
r.stop;
u.stop;
// now try to resume the task
// TempoClock.default hasn't been stopped
// it is definitely running!
// but nothing is posted
r.play(argClock: TempoClock.default);
// also try -- no difference
r.play(argClock: TempoClock.default, doReset: true);
Apparently the “reschedule” block does something funky to the Task’s state. But, as far as I can see, the last line (play with reset) should restore everything to a functioning state… but it doesn’t.
I’m out of time, and this isn’t critical for my own use cases, so I’m going to leave it here… anyone else able to figure it out?
hjh