hadihariri | 7db5553 | 2018-09-15 10:35:08 +0200 | [diff] [blame] | 1 | <!--- INCLUDE .*/example-([a-z]+)-([0-9a-z]+)\.kt |
| 2 | /* |
| 3 | * Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. |
| 4 | */ |
| 5 | |
| 6 | // This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. |
Roman Elizarov | 0950dfa | 2018-07-13 10:33:25 +0300 | [diff] [blame^] | 7 | package kotlinx.coroutines.guide.$$1$$2 |
hadihariri | 7db5553 | 2018-09-15 10:35:08 +0200 | [diff] [blame] | 8 | |
Roman Elizarov | 0950dfa | 2018-07-13 10:33:25 +0300 | [diff] [blame^] | 9 | import kotlinx.coroutines.* |
hadihariri | 7db5553 | 2018-09-15 10:35:08 +0200 | [diff] [blame] | 10 | --> |
| 11 | <!--- KNIT ../core/kotlinx-coroutines-core/test/guide/.*\.kt --> |
| 12 | <!--- TEST_OUT ../core/kotlinx-coroutines-core/test/guide/test/SharedStateGuideTest.kt |
| 13 | // This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. |
Roman Elizarov | 0950dfa | 2018-07-13 10:33:25 +0300 | [diff] [blame^] | 14 | package kotlinx.coroutines.guide.test |
hadihariri | 7db5553 | 2018-09-15 10:35:08 +0200 | [diff] [blame] | 15 | |
| 16 | import org.junit.Test |
| 17 | |
| 18 | class SharedStateGuideTest { |
| 19 | --> |
| 20 | ## Table of contents |
| 21 | |
| 22 | <!--- TOC --> |
| 23 | |
| 24 | * [Shared mutable state and concurrency](#shared-mutable-state-and-concurrency) |
| 25 | * [The problem](#the-problem) |
| 26 | * [Volatiles are of no help](#volatiles-are-of-no-help) |
| 27 | * [Thread-safe data structures](#thread-safe-data-structures) |
| 28 | * [Thread confinement fine-grained](#thread-confinement-fine-grained) |
| 29 | * [Thread confinement coarse-grained](#thread-confinement-coarse-grained) |
| 30 | * [Mutual exclusion](#mutual-exclusion) |
| 31 | * [Actors](#actors) |
| 32 | |
| 33 | <!--- END_TOC --> |
| 34 | |
| 35 | ## Shared mutable state and concurrency |
| 36 | |
| 37 | Coroutines can be executed concurrently using a multi-threaded dispatcher like the [Dispatchers.Default]. It presents |
| 38 | all the usual concurrency problems. The main problem being synchronization of access to **shared mutable state**. |
| 39 | Some solutions to this problem in the land of coroutines are similar to the solutions in the multi-threaded world, |
| 40 | but others are unique. |
| 41 | |
| 42 | ### The problem |
| 43 | |
| 44 | Let us launch a hundred coroutines all doing the same action thousand times. |
| 45 | We'll also measure their completion time for further comparisons: |
| 46 | |
| 47 | <!--- INCLUDE .*/example-sync-03.kt |
| 48 | import java.util.concurrent.atomic.* |
| 49 | --> |
| 50 | |
| 51 | <!--- INCLUDE .*/example-sync-06.kt |
Roman Elizarov | 0950dfa | 2018-07-13 10:33:25 +0300 | [diff] [blame^] | 52 | import kotlinx.coroutines.sync.* |
hadihariri | 7db5553 | 2018-09-15 10:35:08 +0200 | [diff] [blame] | 53 | --> |
| 54 | |
| 55 | <!--- INCLUDE .*/example-sync-07.kt |
Roman Elizarov | 0950dfa | 2018-07-13 10:33:25 +0300 | [diff] [blame^] | 56 | import kotlinx.coroutines.channels.* |
hadihariri | 7db5553 | 2018-09-15 10:35:08 +0200 | [diff] [blame] | 57 | --> |
| 58 | |
| 59 | <!--- INCLUDE .*/example-sync-([0-9a-z]+).kt |
| 60 | import kotlin.system.* |
Roman Elizarov | 0950dfa | 2018-07-13 10:33:25 +0300 | [diff] [blame^] | 61 | import kotlin.coroutines.* |
hadihariri | 7db5553 | 2018-09-15 10:35:08 +0200 | [diff] [blame] | 62 | --> |
| 63 | |
Alexander Prendota | cbeef10 | 2018-09-27 18:42:04 +0300 | [diff] [blame] | 64 | <div class="sample" markdown="1" theme="idea" data-highlight-only> |
| 65 | |
hadihariri | 7db5553 | 2018-09-15 10:35:08 +0200 | [diff] [blame] | 66 | ```kotlin |
| 67 | suspend fun CoroutineScope.massiveRun(action: suspend () -> Unit) { |
| 68 | val n = 100 // number of coroutines to launch |
| 69 | val k = 1000 // times an action is repeated by each coroutine |
| 70 | val time = measureTimeMillis { |
| 71 | val jobs = List(n) { |
| 72 | launch { |
| 73 | repeat(k) { action() } |
| 74 | } |
| 75 | } |
| 76 | jobs.forEach { it.join() } |
| 77 | } |
| 78 | println("Completed ${n * k} actions in $time ms") |
| 79 | } |
| 80 | ``` |
| 81 | |
Alexander Prendota | cbeef10 | 2018-09-27 18:42:04 +0300 | [diff] [blame] | 82 | </div> |
| 83 | |
hadihariri | 7db5553 | 2018-09-15 10:35:08 +0200 | [diff] [blame] | 84 | <!--- INCLUDE .*/example-sync-([0-9a-z]+).kt --> |
| 85 | |
| 86 | We start with a very simple action that increments a shared mutable variable using |
| 87 | multi-threaded [Dispatchers.Default] that is used in [GlobalScope]. |
| 88 | |
Alexander Prendota | cbeef10 | 2018-09-27 18:42:04 +0300 | [diff] [blame] | 89 | <div class="sample" markdown="1" theme="idea" data-highlight-only> |
| 90 | |
hadihariri | 7db5553 | 2018-09-15 10:35:08 +0200 | [diff] [blame] | 91 | ```kotlin |
| 92 | var counter = 0 |
| 93 | |
| 94 | fun main(args: Array<String>) = runBlocking<Unit> { |
| 95 | GlobalScope.massiveRun { |
| 96 | counter++ |
| 97 | } |
| 98 | println("Counter = $counter") |
| 99 | } |
| 100 | ``` |
| 101 | |
Alexander Prendota | cbeef10 | 2018-09-27 18:42:04 +0300 | [diff] [blame] | 102 | </div> |
| 103 | |
hadihariri | 7db5553 | 2018-09-15 10:35:08 +0200 | [diff] [blame] | 104 | > You can get full code [here](../core/kotlinx-coroutines-core/test/guide/example-sync-01.kt) |
| 105 | |
| 106 | <!--- TEST LINES_START |
| 107 | Completed 100000 actions in |
| 108 | Counter = |
| 109 | --> |
| 110 | |
| 111 | What does it print at the end? It is highly unlikely to ever print "Counter = 100000", because a thousand coroutines |
| 112 | increment the `counter` concurrently from multiple threads without any synchronization. |
| 113 | |
| 114 | > Note: if you have an old system with 2 or fewer CPUs, then you _will_ consistently see 100000, because |
| 115 | the thread pool is running in only one thread in this case. To reproduce the problem you'll need to make the |
| 116 | following change: |
| 117 | |
Alexander Prendota | cbeef10 | 2018-09-27 18:42:04 +0300 | [diff] [blame] | 118 | <div class="sample" markdown="1" theme="idea" data-highlight-only> |
| 119 | |
hadihariri | 7db5553 | 2018-09-15 10:35:08 +0200 | [diff] [blame] | 120 | ```kotlin |
| 121 | val mtContext = newFixedThreadPoolContext(2, "mtPool") // explicitly define context with two threads |
| 122 | var counter = 0 |
| 123 | |
| 124 | fun main(args: Array<String>) = runBlocking<Unit> { |
| 125 | CoroutineScope(mtContext).massiveRun { // use it instead of Dispatchers.Default in this sample and below |
| 126 | counter++ |
| 127 | } |
| 128 | println("Counter = $counter") |
| 129 | } |
| 130 | ``` |
| 131 | |
Alexander Prendota | cbeef10 | 2018-09-27 18:42:04 +0300 | [diff] [blame] | 132 | </div> |
| 133 | |
hadihariri | 7db5553 | 2018-09-15 10:35:08 +0200 | [diff] [blame] | 134 | > You can get full code [here](../core/kotlinx-coroutines-core/test/guide/example-sync-01b.kt) |
| 135 | |
| 136 | <!--- TEST LINES_START |
| 137 | Completed 100000 actions in |
| 138 | Counter = |
| 139 | --> |
| 140 | |
| 141 | ### Volatiles are of no help |
| 142 | |
| 143 | There is common misconception that making a variable `volatile` solves concurrency problem. Let us try it: |
| 144 | |
Alexander Prendota | cbeef10 | 2018-09-27 18:42:04 +0300 | [diff] [blame] | 145 | <div class="sample" markdown="1" theme="idea" data-highlight-only> |
| 146 | |
hadihariri | 7db5553 | 2018-09-15 10:35:08 +0200 | [diff] [blame] | 147 | ```kotlin |
| 148 | @Volatile // in Kotlin `volatile` is an annotation |
| 149 | var counter = 0 |
| 150 | |
| 151 | fun main(args: Array<String>) = runBlocking<Unit> { |
| 152 | GlobalScope.massiveRun { |
| 153 | counter++ |
| 154 | } |
| 155 | println("Counter = $counter") |
| 156 | } |
| 157 | ``` |
| 158 | |
Alexander Prendota | cbeef10 | 2018-09-27 18:42:04 +0300 | [diff] [blame] | 159 | </div> |
| 160 | |
hadihariri | 7db5553 | 2018-09-15 10:35:08 +0200 | [diff] [blame] | 161 | > You can get full code [here](../core/kotlinx-coroutines-core/test/guide/example-sync-02.kt) |
| 162 | |
| 163 | <!--- TEST LINES_START |
| 164 | Completed 100000 actions in |
| 165 | Counter = |
| 166 | --> |
| 167 | |
| 168 | This code works slower, but we still don't get "Counter = 100000" at the end, because volatile variables guarantee |
| 169 | linearizable (this is a technical term for "atomic") reads and writes to the corresponding variable, but |
| 170 | do not provide atomicity of larger actions (increment in our case). |
| 171 | |
| 172 | ### Thread-safe data structures |
| 173 | |
| 174 | The general solution that works both for threads and for coroutines is to use a thread-safe (aka synchronized, |
| 175 | linearizable, or atomic) data structure that provides all the necessarily synchronization for the corresponding |
| 176 | operations that needs to be performed on a shared state. |
| 177 | In the case of a simple counter we can use `AtomicInteger` class which has atomic `incrementAndGet` operations: |
| 178 | |
Alexander Prendota | cbeef10 | 2018-09-27 18:42:04 +0300 | [diff] [blame] | 179 | <div class="sample" markdown="1" theme="idea" data-highlight-only> |
| 180 | |
hadihariri | 7db5553 | 2018-09-15 10:35:08 +0200 | [diff] [blame] | 181 | ```kotlin |
| 182 | var counter = AtomicInteger() |
| 183 | |
| 184 | fun main(args: Array<String>) = runBlocking<Unit> { |
| 185 | GlobalScope.massiveRun { |
| 186 | counter.incrementAndGet() |
| 187 | } |
| 188 | println("Counter = ${counter.get()}") |
| 189 | } |
| 190 | ``` |
| 191 | |
Alexander Prendota | cbeef10 | 2018-09-27 18:42:04 +0300 | [diff] [blame] | 192 | </div> |
| 193 | |
hadihariri | 7db5553 | 2018-09-15 10:35:08 +0200 | [diff] [blame] | 194 | > You can get full code [here](../core/kotlinx-coroutines-core/test/guide/example-sync-03.kt) |
| 195 | |
| 196 | <!--- TEST ARBITRARY_TIME |
| 197 | Completed 100000 actions in xxx ms |
| 198 | Counter = 100000 |
| 199 | --> |
| 200 | |
| 201 | This is the fastest solution for this particular problem. It works for plain counters, collections, queues and other |
| 202 | standard data structures and basic operations on them. However, it does not easily scale to complex |
| 203 | state or to complex operations that do not have ready-to-use thread-safe implementations. |
| 204 | |
| 205 | ### Thread confinement fine-grained |
| 206 | |
| 207 | _Thread confinement_ is an approach to the problem of shared mutable state where all access to the particular shared |
| 208 | state is confined to a single thread. It is typically used in UI applications, where all UI state is confined to |
| 209 | the single event-dispatch/application thread. It is easy to apply with coroutines by using a |
| 210 | single-threaded context. |
| 211 | |
Alexander Prendota | cbeef10 | 2018-09-27 18:42:04 +0300 | [diff] [blame] | 212 | <div class="sample" markdown="1" theme="idea" data-highlight-only> |
| 213 | |
hadihariri | 7db5553 | 2018-09-15 10:35:08 +0200 | [diff] [blame] | 214 | ```kotlin |
| 215 | val counterContext = newSingleThreadContext("CounterContext") |
| 216 | var counter = 0 |
| 217 | |
| 218 | fun main(args: Array<String>) = runBlocking<Unit> { |
| 219 | GlobalScope.massiveRun { // run each coroutine with DefaultDispathcer |
| 220 | withContext(counterContext) { // but confine each increment to the single-threaded context |
| 221 | counter++ |
| 222 | } |
| 223 | } |
| 224 | println("Counter = $counter") |
| 225 | } |
| 226 | ``` |
| 227 | |
Alexander Prendota | cbeef10 | 2018-09-27 18:42:04 +0300 | [diff] [blame] | 228 | </div> |
| 229 | |
hadihariri | 7db5553 | 2018-09-15 10:35:08 +0200 | [diff] [blame] | 230 | > You can get full code [here](../core/kotlinx-coroutines-core/test/guide/example-sync-04.kt) |
| 231 | |
| 232 | <!--- TEST ARBITRARY_TIME |
| 233 | Completed 100000 actions in xxx ms |
| 234 | Counter = 100000 |
| 235 | --> |
| 236 | |
| 237 | This code works very slowly, because it does _fine-grained_ thread-confinement. Each individual increment switches |
| 238 | from multi-threaded [Dispatchers.Default] context to the single-threaded context using [withContext] block. |
| 239 | |
| 240 | ### Thread confinement coarse-grained |
| 241 | |
| 242 | In practice, thread confinement is performed in large chunks, e.g. big pieces of state-updating business logic |
| 243 | are confined to the single thread. The following example does it like that, running each coroutine in |
| 244 | the single-threaded context to start with. |
| 245 | Here we use [CoroutineScope()] function to convert coroutine context reference to [CoroutineScope]: |
| 246 | |
Alexander Prendota | cbeef10 | 2018-09-27 18:42:04 +0300 | [diff] [blame] | 247 | <div class="sample" markdown="1" theme="idea" data-highlight-only> |
| 248 | |
hadihariri | 7db5553 | 2018-09-15 10:35:08 +0200 | [diff] [blame] | 249 | ```kotlin |
| 250 | val counterContext = newSingleThreadContext("CounterContext") |
| 251 | var counter = 0 |
| 252 | |
| 253 | fun main(args: Array<String>) = runBlocking<Unit> { |
| 254 | CoroutineScope(counterContext).massiveRun { // run each coroutine in the single-threaded context |
| 255 | counter++ |
| 256 | } |
| 257 | println("Counter = $counter") |
| 258 | } |
| 259 | ``` |
| 260 | |
Alexander Prendota | cbeef10 | 2018-09-27 18:42:04 +0300 | [diff] [blame] | 261 | </div> |
| 262 | |
hadihariri | 7db5553 | 2018-09-15 10:35:08 +0200 | [diff] [blame] | 263 | > You can get full code [here](../core/kotlinx-coroutines-core/test/guide/example-sync-05.kt) |
| 264 | |
| 265 | <!--- TEST ARBITRARY_TIME |
| 266 | Completed 100000 actions in xxx ms |
| 267 | Counter = 100000 |
| 268 | --> |
| 269 | |
| 270 | This now works much faster and produces correct result. |
| 271 | |
| 272 | ### Mutual exclusion |
| 273 | |
| 274 | Mutual exclusion solution to the problem is to protect all modifications of the shared state with a _critical section_ |
| 275 | that is never executed concurrently. In a blocking world you'd typically use `synchronized` or `ReentrantLock` for that. |
| 276 | Coroutine's alternative is called [Mutex]. It has [lock][Mutex.lock] and [unlock][Mutex.unlock] functions to |
| 277 | delimit a critical section. The key difference is that `Mutex.lock()` is a suspending function. It does not block a thread. |
| 278 | |
| 279 | There is also [withLock] extension function that conveniently represents |
| 280 | `mutex.lock(); try { ... } finally { mutex.unlock() }` pattern: |
| 281 | |
Alexander Prendota | cbeef10 | 2018-09-27 18:42:04 +0300 | [diff] [blame] | 282 | <div class="sample" markdown="1" theme="idea" data-highlight-only> |
| 283 | |
hadihariri | 7db5553 | 2018-09-15 10:35:08 +0200 | [diff] [blame] | 284 | ```kotlin |
| 285 | val mutex = Mutex() |
| 286 | var counter = 0 |
| 287 | |
| 288 | fun main(args: Array<String>) = runBlocking<Unit> { |
| 289 | GlobalScope.massiveRun { |
| 290 | mutex.withLock { |
| 291 | counter++ |
| 292 | } |
| 293 | } |
| 294 | println("Counter = $counter") |
| 295 | } |
| 296 | ``` |
| 297 | |
Alexander Prendota | cbeef10 | 2018-09-27 18:42:04 +0300 | [diff] [blame] | 298 | </div> |
| 299 | |
hadihariri | 7db5553 | 2018-09-15 10:35:08 +0200 | [diff] [blame] | 300 | > You can get full code [here](../core/kotlinx-coroutines-core/test/guide/example-sync-06.kt) |
| 301 | |
| 302 | <!--- TEST ARBITRARY_TIME |
| 303 | Completed 100000 actions in xxx ms |
| 304 | Counter = 100000 |
| 305 | --> |
| 306 | |
| 307 | The locking in this example is fine-grained, so it pays the price. However, it is a good choice for some situations |
| 308 | where you absolutely must modify some shared state periodically, but there is no natural thread that this state |
| 309 | is confined to. |
| 310 | |
| 311 | ### Actors |
| 312 | |
| 313 | An [actor](https://en.wikipedia.org/wiki/Actor_model) is an entity made up of a combination of a coroutine, the state that is confined and encapsulated into this coroutine, |
| 314 | and a channel to communicate with other coroutines. A simple actor can be written as a function, |
| 315 | but an actor with a complex state is better suited for a class. |
| 316 | |
| 317 | There is an [actor] coroutine builder that conveniently combines actor's mailbox channel into its |
| 318 | scope to receive messages from and combines the send channel into the resulting job object, so that a |
| 319 | single reference to the actor can be carried around as its handle. |
| 320 | |
| 321 | The first step of using an actor is to define a class of messages that an actor is going to process. |
| 322 | Kotlin's [sealed classes](https://kotlinlang.org/docs/reference/sealed-classes.html) are well suited for that purpose. |
| 323 | We define `CounterMsg` sealed class with `IncCounter` message to increment a counter and `GetCounter` message |
| 324 | to get its value. The later needs to send a response. A [CompletableDeferred] communication |
| 325 | primitive, that represents a single value that will be known (communicated) in the future, |
| 326 | is used here for that purpose. |
| 327 | |
Alexander Prendota | cbeef10 | 2018-09-27 18:42:04 +0300 | [diff] [blame] | 328 | <div class="sample" markdown="1" theme="idea" data-highlight-only> |
| 329 | |
hadihariri | 7db5553 | 2018-09-15 10:35:08 +0200 | [diff] [blame] | 330 | ```kotlin |
| 331 | // Message types for counterActor |
| 332 | sealed class CounterMsg |
| 333 | object IncCounter : CounterMsg() // one-way message to increment counter |
| 334 | class GetCounter(val response: CompletableDeferred<Int>) : CounterMsg() // a request with reply |
| 335 | ``` |
| 336 | |
Alexander Prendota | cbeef10 | 2018-09-27 18:42:04 +0300 | [diff] [blame] | 337 | </div> |
| 338 | |
hadihariri | 7db5553 | 2018-09-15 10:35:08 +0200 | [diff] [blame] | 339 | Then we define a function that launches an actor using an [actor] coroutine builder: |
| 340 | |
Alexander Prendota | cbeef10 | 2018-09-27 18:42:04 +0300 | [diff] [blame] | 341 | <div class="sample" markdown="1" theme="idea" data-highlight-only> |
| 342 | |
hadihariri | 7db5553 | 2018-09-15 10:35:08 +0200 | [diff] [blame] | 343 | ```kotlin |
| 344 | // This function launches a new counter actor |
| 345 | fun CoroutineScope.counterActor() = actor<CounterMsg> { |
| 346 | var counter = 0 // actor state |
| 347 | for (msg in channel) { // iterate over incoming messages |
| 348 | when (msg) { |
| 349 | is IncCounter -> counter++ |
| 350 | is GetCounter -> msg.response.complete(counter) |
| 351 | } |
| 352 | } |
| 353 | } |
| 354 | ``` |
| 355 | |
Alexander Prendota | cbeef10 | 2018-09-27 18:42:04 +0300 | [diff] [blame] | 356 | </div> |
| 357 | |
hadihariri | 7db5553 | 2018-09-15 10:35:08 +0200 | [diff] [blame] | 358 | The main code is straightforward: |
| 359 | |
Alexander Prendota | cbeef10 | 2018-09-27 18:42:04 +0300 | [diff] [blame] | 360 | <div class="sample" markdown="1" theme="idea" data-highlight-only> |
| 361 | |
hadihariri | 7db5553 | 2018-09-15 10:35:08 +0200 | [diff] [blame] | 362 | ```kotlin |
| 363 | fun main(args: Array<String>) = runBlocking<Unit> { |
| 364 | val counter = counterActor() // create the actor |
| 365 | GlobalScope.massiveRun { |
| 366 | counter.send(IncCounter) |
| 367 | } |
| 368 | // send a message to get a counter value from an actor |
| 369 | val response = CompletableDeferred<Int>() |
| 370 | counter.send(GetCounter(response)) |
| 371 | println("Counter = ${response.await()}") |
| 372 | counter.close() // shutdown the actor |
| 373 | } |
| 374 | ``` |
| 375 | |
Alexander Prendota | cbeef10 | 2018-09-27 18:42:04 +0300 | [diff] [blame] | 376 | </div> |
| 377 | |
hadihariri | 7db5553 | 2018-09-15 10:35:08 +0200 | [diff] [blame] | 378 | > You can get full code [here](../core/kotlinx-coroutines-core/test/guide/example-sync-07.kt) |
| 379 | |
| 380 | <!--- TEST ARBITRARY_TIME |
| 381 | Completed 100000 actions in xxx ms |
| 382 | Counter = 100000 |
| 383 | --> |
| 384 | |
| 385 | It does not matter (for correctness) what context the actor itself is executed in. An actor is |
| 386 | a coroutine and a coroutine is executed sequentially, so confinement of the state to the specific coroutine |
| 387 | works as a solution to the problem of shared mutable state. Indeed, actors may modify their own private state, but can only affect each other through messages (avoiding the need for any locks). |
| 388 | |
| 389 | Actor is more efficient than locking under load, because in this case it always has work to do and it does not |
| 390 | have to switch to a different context at all. |
| 391 | |
| 392 | > Note, that an [actor] coroutine builder is a dual of [produce] coroutine builder. An actor is associated |
| 393 | with the channel that it receives messages from, while a producer is associated with the channel that it |
| 394 | sends elements to. |
Roman Elizarov | 99c28aa | 2018-09-23 18:42:36 +0300 | [diff] [blame] | 395 | |
| 396 | <!--- MODULE kotlinx-coroutines-core --> |
Roman Elizarov | 0950dfa | 2018-07-13 10:33:25 +0300 | [diff] [blame^] | 397 | <!--- INDEX kotlinx.coroutines --> |
| 398 | [Dispatchers.Default]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-dispatchers/-default.html |
| 399 | [GlobalScope]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-global-scope/index.html |
| 400 | [withContext]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/with-context.html |
| 401 | [CoroutineScope()]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope.html |
| 402 | [CoroutineScope]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html |
| 403 | [CompletableDeferred]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-completable-deferred/index.html |
| 404 | <!--- INDEX kotlinx.coroutines.sync --> |
| 405 | [Mutex]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.sync/-mutex/index.html |
| 406 | [Mutex.lock]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.sync/-mutex/lock.html |
| 407 | [Mutex.unlock]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.sync/-mutex/unlock.html |
| 408 | [withLock]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.sync/with-lock.html |
| 409 | <!--- INDEX kotlinx.coroutines.channels --> |
| 410 | [actor]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.channels/actor.html |
| 411 | [produce]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.channels/produce.html |
Roman Elizarov | 99c28aa | 2018-09-23 18:42:36 +0300 | [diff] [blame] | 412 | <!--- END --> |