博客
关于我
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/

你可能感兴趣的文章
Oracle 12c安装报错Installation failed to access the temporary location(无法访问临时位置)...
查看>>
Oracle 9i数据库管理教程
查看>>
ORACLE Active dataguard 一个latch: row cache objects BUG
查看>>
oracle avg、count、max、min、sum、having、any、all、nvl的用法
查看>>
Oracle BEQ方式连接配置
查看>>
oracle Blob保存方式,oracle 存储过程操作blob
查看>>
Oracle BMW Racing sailing vessel帆船图
查看>>
ORACLE Bug 4431215 引发的血案—原因分析篇
查看>>
Oracle Business Intelligence Downloads
查看>>
Oracle cmd乱码
查看>>
Oracle Corp甲骨文公司推出Oracle NoSQL数据库2.0版
查看>>
【Docker知识】将环境变量传递到容器
查看>>
uniapp超全user-agent判断 包括微信开发工具 hbuilder mac windows 安卓ios端及本地识别
查看>>
Oracle DBA课程系列笔记(20)
查看>>
oracle dblink 创建使用 垮库转移数据
查看>>
oracle dblink结合同义词的用法 PLS-00352:无法访问另一数据库
查看>>
Oracle dbms_job.submit参数错误导致问题(ora-12011 无法执行1作业)
查看>>
oracle dg switchover,DG Switchover fails
查看>>
Oracle E-Business Suite软件 任意文件上传漏洞(CVE-2022-21587)
查看>>
Oracle EBS OPM 发放生产批
查看>>