How does code in main thread and its runloop interact? For example, does all code in main thread have to run until it is idle before hitting the runloop? Or does runloop check its sources in the middle of executing the code in main thread? Is it possible for runloop source to block main thread code from executing (since it's running on the same thread)?
I am trying to understand how main thread code fits into the picture of runloop (or vice versa) in the grand scheme of things.
Is this how a runloop looks like alongside our code:
Main thread:
- runloop runs at a specific interval
- runloop is done running, our code runs
- our code is done running, go to (1) (What if our code runs so long that runloop doesn't get a chance to run?)