zoukankan      html  css  js  c++  java
  • run loop

    Run Loops

    A run loop is a piece of infrastructure used to manage events arriving asynchronously on a thread. A run loop works by monitoring one or more event sources for the thread. As events arrive, the system wakes up the thread and dispatches the events to the run loop, which then dispatches them to the handlers you specify. If no events are present and ready to be handled, the run loop puts the thread to sleep. 

    You are not required to use a run loop with any threads you create but doing so can provide a better experience for the user. Run loops make it possible to create long-lived threads that use a minimal amount of resources. Because a run loop puts its thread to sleep when there is nothing to do, it eliminates the need for polling, which wastes CPU cycles and prevents the processor itself from sleeping and saving power. 

    To configure a run loop, all you have to do is launch your thread, get a reference to the run loop object, install your event handlers, and tell the run loop to run. The infrastructure provided by OS X handles the configuration of the main thread’s run loop for you automatically. If you plan to create long-lived secondary threads, however, you must configure the run loop for those threads yourself.

    Details about run loops and examples of how to use them are provided in Run Loops

    https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/Multithreading/AboutThreads/AboutThreads.html#//apple_ref/doc/uid/10000057i-CH6-SW3

  • 相关阅读:
    HTML Rendering Error
    PyCharm将选中的内容加上引号
    Scrapy中的Request和日志分析
    PyCharm关闭按两次Shift进入搜索框的功能
    博客园更换模板的链接
    Scrapy的Spider类和CrawlSpider类
    Scrapy安装和简单使用
    计算π的近似值
    Python用pip安装第三方库时换源下载
    网页解析 -- bs4 和 xpath 的简单使用
  • 原文地址:https://www.cnblogs.com/feng9exe/p/8024729.html
Copyright © 2011-2022 走看看