- 博客(4)
- 收藏
- 关注
原创 在suspendCoroutine中用throw代替resumeWithException
举个例子 suspend fun foo() { try { suspendCoroutine { cont -> throw Error() } } catch (ex: Throwable) { println("catch") } println("done") } 这样throw其实和cont.resumeWithE...
2018-04-04 11:21:39 2244
原创 扁平化类型参数
语言:java 一个奇怪的要求:class Foo<A> { public <B> Foo<B> foo(Foo<A> a) {...} }class Bar<A> { public <B> Bar<B> foo(Bar<A> a) {...} } 要求为Foo和Bar抽出一个接口 这个来源于想要在Kotlin里实现Functor,Applicative和Monad的接口,
2018-01-06 20:57:45 791
原创 Kotlin Coroutine (二)
上一篇说完了协程的整个生命周期,总结一下: 用Coroutine Builder函数(launch,startCoroutine等)创建协程 库内部使用createCoroutineUnchecked来创建协程,需要借助编译器的帮助 协程中的指令开始顺序执行 调用另一个suspend函数,直到调用到suspendCoroutine系列的函数 如果suspendCoroutine在同步返回前
2018-01-05 14:42:56 303
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人