{"id":21970,"date":"2018-06-28T16:13:47","date_gmt":"2018-06-28T20:13:47","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=21970"},"modified":"2018-06-28T16:13:47","modified_gmt":"2018-06-28T20:13:47","slug":"run-runloop-run","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2018\/06\/28\/run-runloop-run\/","title":{"rendered":"Run, RunLoop, Run"},"content":{"rendered":"<p><a href=\"https:\/\/bou.io\/RunRunLoopRun.html\">Nicolas Bouilleaud<\/a> (<a href=\"https:\/\/twitter.com\/_nb\/status\/1012051094418219008\">tweet<\/a>):<\/p>\n<blockquote cite=\"https:\/\/bou.io\/RunRunLoopRun.html\"><p>Put simply, a run loop is a messaging mechanism, used for asynchronous or interthread communication. It can be seen as a post box that waits for messages and delivers them to recipients.<\/p>\n\n<p>A run loop does two things:<\/p>\n\n<ul>\n  <li>wait until something happens (e.g., a message arrives),<\/li>\n  <li>dispatch that message to its receiver.<\/li>\n<\/ul>\n<p>[&#8230;]<\/p>\n<p>The most important feature of CFRunLoop is the CFRunLoopModes. CFRunLoop works with a system of &ldquo;Run Loop Sources&rdquo;. Sources are registered on a run loop for one or several modes, and the run loop itself is made to run in a given mode. When an event arrives on a source, it is only handled by the run loop if the source mode matches the run loop current mode.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/gparker\/status\/1012058513567125504\">Greg Parker<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/gparker\/status\/1012058513567125504\">\n<p>1. Write an event-handling loop: it waits for events&mdash;user input, timers, etc&mdash;and calls the handlers registered for those events.<\/p>\n<p>2. Put the loop in an opaque box. That&rsquo;s a run loop object.<\/p>\n<p>I imagine it as a jack-in-the-box. You turn the crank and calls to event handlers pop out.<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Nicolas Bouilleaud (tweet): Put simply, a run loop is a messaging mechanism, used for asynchronous or interthread communication. It can be seen as a post box that waits for messages and delivers them to recipients. A run loop does two things: wait until something happens (e.g., a message arrives), dispatch that message to its receiver. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2018-06-28T20:13:50Z","apple_news_api_id":"98f22a3a-7fb4-4363-91fa-91ffc7df1737","apple_news_api_modified_at":"2018-06-28T20:13:51Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/AmPIqOn-0Q2OR-pH_x98XNw","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[69,31,30,71],"class_list":["post-21970","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-cocoa","tag-ios","tag-mac","tag-programming"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/21970","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=21970"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/21970\/revisions"}],"predecessor-version":[{"id":21971,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/21970\/revisions\/21971"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=21970"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=21970"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=21970"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}