commit | eb62668a4384b13dda0f1862b9feea322b6a6d65 | [log] [tgz] |
---|---|---|
author | Denis Zharkov <denis.zharkov@jetbrains.com> | Thu Jun 23 13:28:50 2016 +0300 |
committer | Denis Zharkov <denis.zharkov@jetbrains.com> | Thu Jun 23 13:28:50 2016 +0300 |
tree | e99a893b723f4e0e50c5771774a62f8bd38d33f9 | |
parent | 4d286e0f2790e9ed02ebf4bbe4d59a2cb02001df [diff] |
Fix version in README.md
Two libraries built upon Kotlin coroutines:
kotlinx-coroutines-async
with convenient interfaces/wrappers to commonly used asynchronous API shipped with standard JDK, namely promise-like CompletableFuture
and asynchronous channels from java.nio
packagekotlinx-coroutines-generate
provides ability to create Sequence
objects generated by coroutine body containing yield
suspension pointsimport kotlinx.coroutines.async import java.util.concurrent.CompletableFuture private fun startLongAsyncOperation(v: Int) = CompletableFuture.supplyAsync { Thread.sleep(1000) "Result: $v" } fun main(args: Array<String>) { val future = async<String> { (1..5).map { await(startLongAsyncOperation(it)) }.joinToString("\n") } println(future.get()) }
import kotlinx.coroutines.generate fun main(args: Array<String>) { val sequence = generate<Int> { for (i in 1..5) { yield(i) } } println(sequence.joinToString(" ")) }
For more examples you can look at kotlinx-coroutines-async-example-ui
sample project or in tests directories.
Add jcenter repository (if you don't have it yet)
<repository> <snapshots> <enabled>false</enabled> </snapshots> <id>dl</id> <name>bintray</name> <url>http://dl.bintray.com/kotlin/kotlinx.coroutines</url> </repository>
Add a dependency:
<dependency> <groupId>org.jetbrains.kotlinx</groupId> <artifactId>kotlinx-coroutines-generate</artifactId> <version>0.1-alpha-1</version> </dependency>
Just add a dependency:
compile 'org.jetbrains.kotlinx:kotlinx-coroutines-generate:0.1-alpha-1'
jcenter repository should be configured by default in gradle, but if it's not you may need to include it:
repositories { maven { url "http://dl.bintray.com/kotlin/kotlinx.coroutines" } }