Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Changes
Page history
Update Kotlin coroutines
authored
Jul 31, 2023
by
umaumax
Hide whitespace changes
Inline
Side-by-side
Kotlin-coroutines.md
View page @
64117f3f
...
...
@@ -236,6 +236,12 @@ for (i in 1..100) {
c++のように、mutexなどを利用したlock/unlockは不要であるが、切り替えタイミングによって、値が意図せずに変更される可能性があることに注意する必要がある
### キャンセル
#### suspendな関数を呼び出さないコルーチンをキャンセル可能にする
CPUバウンドな処理を行うコルーチンでは基本的にsuspendな関数を呼び出さないので、
キャンセル可能なポイントがないため、これをキャンセルしたい場合には明示的にキャンセルをするタイミングを用意する必要がある
例えば、
`yield()`
か
`ensureActive()`
を呼び出せばよい
#### 例外
*
[
Kotlin CoroutinesのCancellationの罠 | Wantedly Engineer Blog
](
https://www.wantedly.com/companies/wantedly/post_articles/315112
)
...
...
...
...