I’m using apple’s AVAudioEngine code like this:
var audioEngine = AVAudioEngine()
audioEngine.inputNode.installTap { [buffer, when] in
let waveform = myGetWaveform(buffer)
Task {
Something.shared.doSomethingWith(waveform)
}
}
I do this because Something
is an actor
, and it’s hard for me to change it. But of course, the problem is that those Task
s can be executed out of order. That would be bad – I need them to be executed in order. How can I guarantee they execute in order? I suppose this could be applied to any synchronous code that can’t change the caller to be async. I can’t seem to find any way to inject serialization into async actor code…