NCZZSK

自在生活

  • 主页
所有文章 true

NCZZSK

自在生活

  • 主页

一些宏定义

2018-09-28
  • 主线程同步,避免死锁
    1
    2
    3
    4
    5
    6
    7
    8
    #ifndef dispatch_main_sync_safe
    #define dispatch_main_sync_safe(block)\
    if (strcmp(dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL), dispatch_queue_get_label(dispatch_get_main_queue())) == 0) {\
    block();\
    } else {\
    dispatch_sync(dispatch_get_main_queue(), block);\
    }
    #endif
  • 主线程异步

    1
    2
    3
    4
    5
    6
    7
    8
    #ifndef dispatch_main_async_safe
    #define dispatch_main_async_safe(block)\
    if (strcmp(dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL), dispatch_queue_get_label(dispatch_get_main_queue())) == 0) {\
    block();\
    } else {\
    dispatch_async(dispatch_get_main_queue(), block);\
    }
    #endif
  • dispatch_queue_get_label

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    * @abstract
    * Returns the label of the given queue, as specified when the queue was
    * created, or the empty string if a NULL label was specified.
    *
    * Passing DISPATCH_CURRENT_QUEUE_LABEL will return the label of the current
    *
    *
    * @param queue
    * The queue to query, or DISPATCH_CURRENT_QUEUE_LABEL.

    // 返回指定队列名称,为空返回NULL
    // 入参为队列 or DISPATCH_CURRENT_QUEUE_LABEL
    // DISPATCH_CURRENT_QUEUE_LABEL:表示返回当前队列名称
赏

晚饭加鸡腿🍗

支付宝

扫一扫,分享到微信

微信分享二维码
App从0到1记录
“小程序分享至群群消息小结(包括分享到App)”
© 2019 NCZZSK
Hexo Theme Yilia by Litten
  • 所有文章
  • true

tag:

    缺失模块。
    1、请确保node版本大于6.2
    2、在博客根目录(注意不是yilia根目录)执行以下命令:
    npm i hexo-generator-json-content --save

    3、在根目录_config.yml里添加配置:

      jsonContent:
        meta: false
        pages: false
        posts:
          title: true
          date: true
          path: true
          text: false
          raw: false
          content: false
          slug: false
          updated: false
          comments: false
          link: false
          permalink: false
          excerpt: false
          categories: false
          tags: true
    

一个人如果没有梦想
跟无忧无虑有什么区别呢?

如果你笑了
那就太好啦~