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() 

  • 相关阅读:
    beagle ubuntu
    screen usage
    centos install nginx¢os 添加网易源
    心情舒畅,升级到u10.04了
    nginx 运行,检测
    联通宽带测速
    virtualenv usage
    linux 终端下utf8 和gbk相互转换
    [梦]2005725
    git install on centos
  • 原文地址:https://www.cnblogs.com/Sunnyheart/p/4992828.html
Copyright © 2011-2022 走看看