zoukankan      html  css  js  c++  java
  • GCD 中time使用

    时间常量
    #define DISPATCH_TIME_NOW 0      
    #define DISPATCH_TIME_FOREVER (~0ull)   
     
    #define NSEC_PER_SEC 1000000000ull    // 定义一秒=10亿纳秒
    #define USEC_PER_SEC 1000000ull         // 定义一秒=100万微妙
    #define NSEC_PER_USEC 1000ull            // 定义一微妙=100纳秒
     
    时间换算单位
    1s(秒second)= 1000ms(毫秒millisecond)= 1000 000μs(微妙microsecond) = 1000 000 000ns(纳秒nanosecond)
     
    dispatch_after:延迟指定的时间后将block异步添加到指定队列中
     
    dispatch_time_t dispatch_time(dispatch_time_t when, int64_t delta)
    返回给定时间延迟delta纳秒对应的时间,delta单位是纳秒
     
    实例:延迟0.3秒执行
    dispatch_time_t time = dispatch_time(DISPATCH_TIME_NOW, 0.3*NSEC_PER_SEC);
    dispatch_after(time, dispatch_get_main_queue(), ^{});
  • 相关阅读:
    JavaScript中的__proto__
    移动前端调试页面–weinre
    nodo合并多个mp3文件
    enctype和Content-type有什么关系
    vscode 实用的插件
    前端跨域问题及解决方案
    小小的js
    如何使用eslint
    RN记录
    numpy的索引
  • 原文地址:https://www.cnblogs.com/shuleihen/p/4100788.html
Copyright © 2011-2022 走看看