I'm starting to dig into asynchronous code with Swift and Mac OS. I want to add a sequencer into my app, so I need a loop pretty much like SpriteKit's game loop runs, without the visual library.
What I want to do is a virtual timeline that I can run, pause, stop and use it to schedule actions that will send network messages. I need that to be as accurate as possible, probably running on a high priority thread or using high priority timers.
As long as I get a high precision run loop running on a different thread as the GUI, I'll be good to build the rest. I'm just looking for the best possible way to achieve that in Swift. Any library available to do that so I don't have to do the basic plumbing?
Thanks!
Edit: This loop has to run no matter what even if the app goes in the background.
The plan is to eventually use it as an OSC sequencer to control a sample accurate audio engine (right now I can get around 14000 OSC messages in about 4 seconds, and it will get bigger). It will process the timing of teiggers and actions processing parameters over time (no audio involved in that loop, at least not directly) and possibly generating/syncing to SMPTE timecode to sync with video and audio playback servers. It is important that the timing stays as precise as possible as it could be used (would be) in live events.
So using a high precision timer for accuracy? Or running a GCD thread? I haven't touched async coding in OS X yet, so I just want to get started in the right direction.