博客
关于我
GCD学习之dispatch_suspend/dispatch_resume
阅读量:739 次
发布时间:2019-03-22

本文共 399 字,大约阅读时间需要 1 分钟。

dispatch_suspend/dispatch_resume

dispatch_suspend和dispatch_resume

当Dispatch Queue中处理任务数量过多时,有时可能需要暂停已添加到队列中的任务运行。这种情况通常发生在关键任务被阻止(比如被异常捕获)时。

与之对应的解决方案就是挂起Dispatch Queue。当恢复时,这些被暂停的任务就会继续执行。

具体操作方式如下。

dispatch_suspend(queue);

功能恢复

dispatch_resume(queue);

需要注意的是,这些函数不会影响已经在执行中的任务。当使用dispatch_suspend时,尚未处理的新任务会立即停止。dispatch_resume则会让这些被暂停的任务恢复执行。

GCD工具集中的这两个函数非常实用,能够帮助开发者在关键任务被中断时,通过简单的方式控制队列任务执行流程。

转载地址:http://kmggz.baihongyu.com/

你可能感兴趣的文章
Nginx + Tomcat + SpringBoot 部署项目
查看>>
Nginx + uWSGI + Flask + Vhost
查看>>
Nginx - Header详解
查看>>
nginx - thinkphp 如何实现url的rewrite
查看>>
Nginx - 反向代理、负载均衡、动静分离、底层原理(案例实战分析)
查看>>
Nginx - 反向代理与负载均衡
查看>>
nginx 1.24.0 安装nginx最新稳定版
查看>>
nginx 301 永久重定向
查看>>
nginx connect 模块安装以及配置
查看>>
nginx css,js合并插件,淘宝nginx合并js,css插件
查看>>
Nginx gateway集群和动态网关
查看>>
nginx http配置说明,逐渐完善。
查看>>
Nginx keepalived一主一从高可用,手把手带你一步一步配置!
查看>>
Nginx Location配置总结
查看>>
Nginx log文件写入失败?log文件权限设置问题
查看>>
Nginx Lua install
查看>>
nginx net::ERR_ABORTED 403 (Forbidden)
查看>>
vue中处理过内存泄露处理方法
查看>>
Nginx RTMP 模块使用指南
查看>>
Nginx SSL 性能调优
查看>>