How runloop works

At the beginning of this month I asked this question "What is runloop?" After reading the answers and some attempts, I got it to work, but still I do not fully understand this. If runloop is just a loop associated with a thread, and it does not spawn another thread backstage, as any of the other code in my thread (mainthread so that it is simple) could run without "blocking" / did not start because it is where does an infinite loop do?

This is the number one question. Then to the second.

If I did something while working with this, but not fully understanding that runloop is a loop in which you attach flags that notify runloop that when it comes to the point where the flag is, it stops "and does any handler that is attached at this point? Then it continues to work until the next one in the queue.

runloop

So, in this case, the events are not queued in the connections, but when it comes to events, it takes any actions related to tap 1 and performs it before it connects to the connections again and so on. Or am I, as far as I can understand the concept?

+4
source share
2 answers

"Sorting".

Have you read this specific documentation ?

It goes to a considerable depth - a fairly deep depth - in the architecture and operation of the launch cycles.

+1
source

The start of the loop will be blocked if it sends a method that takes too long or that loop is forever.

This is why the iPhone application will want to do everything that does not fit in 1 β€œtick” of the user interface launch cycle (say, at a certain animation frame rate or user interface response speed) and with room to save on any other event handlers that must be executed in the same "tick", either broken asynchronously, or sent to another thread for execution.

Otherwise, the material will be blocked until control is returned to the run loop.

+1
source

Source: https://habr.com/ru/post/1340354/


All Articles