RunLoop 有什么用 ?
Run Loop 的作用就是敬鬓,有任務(wù),開起進(jìn)程笙各,沒任務(wù)钉答,休眠進(jìn)程。
1杈抢, Observers 的實(shí)現(xiàn)
KVO 就是觀察對(duì)象值的變化数尿,給接收者一個(gè)事件源。有了事件源惶楼,即有任務(wù)右蹦, Run Loop 就會(huì)調(diào)度資源诊杆。
The CFRunLoopObserver API lets you observe the behavior of CFRunLoop and be notified of its activity
activity 的概念
2, block , 回調(diào),就是下輪跑
when you want to run code “on the next loop”.
3, 主派發(fā)隊(duì)列何陆,
That Main Dispatch Queue tag is of course CFRunLoop speaking to Grand Central Dispatch.
4晨汹, Timers, 背后是CFRunLoop timers
high-lever “timers” like NSTimer or performSelector:afterDelay: are implementd using CFRunLoop timers.
參考資料:
Eggs:
感覺 runloop 是 app 的事件流, 事件資源的調(diào)度,怎么處理贷盲。
應(yīng)該算是站在 OS 的角度淘这,程序員作為 VM ,給用戶提供資源那么 runtime 就是巩剖,那肯定是消息流
感覺是站在編譯器的角度铝穷,看著代碼是怎么執(zhí)行的。
程序員作為 VM , 給代碼(寫代碼的人球及,給出指令的氧骤,發(fā)消息的)提供資源