zoukankan      html  css  js  c++  java
  • dispatch_source_t

    dispatch_source_t的作用:监听某些事件,当这些事件发生的时候,他就会把这些事件的回调的block提交到某些队列上变执行。

    @abstract

     * Creates a new dispatch source to monitor low-level system objects and auto-

     * matically submit a handler block to a dispatch queue in response to events. 

    所以使用 dispatch_source_t分为三步:

    1.创建dispatch_source_create(param1,param2,param3,param4)

    参数解释:

        param1:监听的事件类型,比如:DISPATCH_SOURCE_TYPE_TIMER,DISPATCH_SOURCE_TYPE_SIGNAL等

        parma4:当事件发生时,指定回调block放置的队列

    2.设置dipatch_source_t的属性

    比如:dispatch_set_timer(param1,param2,param3,param4)

    参数解释:

        param1: dipatch_source_t变量  

        param3:时间间隔 

    3.设置dipatch_source_t的回调block

    dispatch_source_set_event_handler(param1,param2)

       param1: dipatch_source_t变量

       param2:回调的block

    4.启动 dipatch_source_t

       resume()

    5.取消

       cancel() 

  • 相关阅读:
    AsyncHttpClient使用
    索引
    jdbc--取大量数据
    oracle--with as
    spring--mybatis事务总结
    Elasticsearch环境搭建
    使用idea远程调试
    redis分布式锁的实现
    知识梳理
    Zookeeper
  • 原文地址:https://www.cnblogs.com/Sunnyheart/p/4992828.html
Copyright © 2011-2022 走看看