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

  • 相关阅读:
    复(学)习化学时突然的一个 idea
    [BZOJ3032]七夕祭
    [BZOJ3781]小B的询问
    [BZOJ4103][Thu Summer Camp 2015]异或运算
    [BZOJ4817][Sdoi2017]树点涂色
    [BZOJ2506]calc
    [BZOJ1283]序列
    win 解除鼠标右键关联
    linux 常用shell命令之wc
    shell cat 合并文件,合并数据库sql文件
  • 原文地址:https://www.cnblogs.com/Sunnyheart/p/4992828.html
Copyright © 2011-2022 走看看