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

  • 相关阅读:
    Transaction 'IREG', Abend 'APCT', at '????'.
    CICS中设置是否具有可修改性
    常用命令总结
    常用语句总结
    _func_
    数组排序返回索引-python和c++的实现
    数组的并行求和-cuda实现
    Pytorch 多GPU训练-多计算节点并行-All you need
    Pytorch 多GPU训练-单运算节点-All you need
    Windows 编程中的问题
  • 原文地址:https://www.cnblogs.com/feng9exe/p/8024729.html
Copyright © 2011-2022 走看看