当前位置:网站首页>Kotlin - 协程构建器 CoroutineBuilder
Kotlin - 协程构建器 CoroutineBuilder
2022-07-26 19:31:00 【懒到死的程序员】
CoroutineBuilder
挂起函数需要相互传递 Continuation,每个挂起函数都要由另一个挂起函数调用,这一切都是从协程构建器开始的。每个协程构造器都是CoroutineScope的扩展函数,并继承了它的 coutineContext 来自动传播其上下文元素和可取消性。
- lunch():无需产生值。返回一个 Job实例 用来管理协程的生命周期。异常???
- async():需要产生值。返回一个 Deferred实例 通过 await() 拿到执行的结果(包括异常)。异常???
参数 context:指定协程上下文。 参数 start:指定协程启动方式,默认为可以立刻被调度的状态。 参数 block:协程执行体,即要做的任务。 | |
| lunch() | public fun CoroutineScope.launch( 返回对该协程任务的引用,即 Job 接口的匿名实现。 |
| async() | public fun <T> CoroutineScope.async( 返回协程的执行结果,通过 await() 可以拿到协程的执行结果。 |
边栏推荐
- regular expression
- 计算机组成原理常见面试题目总结,含答案
- 内网渗透学习(二)信息收集
- 2022年下半年(软考高级)信息系统项目管理师报名条件
- Kingbases SQL language reference manual of Jincang database (13. SQL statement: alter synonym to comment)
- Exchange 2010 SSL certificate installation document
- 一文读懂 Kubernetes的四种服务类型!
- numpy.zeros_like
- DevSecOps,让速度和安全兼顾
- numpy.put()
猜你喜欢

Week 6 Convolutional Neural Networks (CNNs)

three. JS tag and pop-up the earth

Vite 配置 Eslint 规范代码

C#异步编程看这篇就够了

使用请求头认证来测试需要授权的 API 接口

A little cool, explore space with.Net Maui

7岁男童因下棋太快?机器人竟夹断其手指

C # use the default transformation method

低代码工具有哪些特色?明眼人都能看出来的低代码两大发展轨迹!

Read the high-performance queue channel in.Net
随机推荐
EtherCAT 同步模式
TableWidget
2022 极术通讯-安谋科技开启商业化新篇章
Kingbasees SQL language reference manual of Jincang database (12. SQL statement: alter language to alter subscription)
【JVM 系列】JVM 调优
Shell script basic programming commands
移动端video兼容你需要知道的几点
C # use the default transformation method
C # convert PDF files into pictures
Definition and use of one-dimensional array
EFCore Migrations的深入研究
Impersonate authentication
.net GC workflow
Vite 配置 Eslint 规范代码
Vs how to read data in MySQL (by the way, the problem of Chinese garbled code is solved through code)
谷歌的新编程语言被称为 Carbon
【ffmpeg】给视频文件添加时间戳 汇总
【Pytorch进阶】pytorch模型的保存与使用
EtherCAT synchronization mode
ES6的方法&类数组转成真正的数组&判断数组的方法