I've written a quick class for 'piping' the contents of an InputStream to multiple OutputStreams. It starts this by doing:
self.from.schedule(in: RunLoop.current, forMode: RunLoopMode.defaultRunLoopMode)
self.to.forEach { to in
to.schedule(in: RunLoop.current, forMode: RunLoopMode.defaultRunLoopMode)
}
This works fine when I'm in the main thread, but if I try to do it on a background thread nothing ever fires. From my research I understand that this is because the RunLoop only automatically runs on the main thread.
It's often a download task, so from my understanding I don't really want that on the main thread. So how can I best have this run on a background queue?