commit | 94e787967a95df578f88d23e4f9465222a1ef1ba | [log] [tgz] |
---|---|---|
author | Denis Zharkov <denis.zharkov@jetbrains.com> | Tue Jun 28 14:38:06 2016 +0300 |
committer | Denis Zharkov <denis.zharkov@jetbrains.com> | Tue Jun 28 14:38:06 2016 +0300 |
tree | 96d914cb2ceb0bd5cc573fa5f774eb8c4e82a0a7 | |
parent | 25e667ca36b38e4978528b1ee4585c000f8bd2a9 [diff] |
Minor. Update 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'
Also you should include our bintray repository:
repositories { maven { url "http://dl.bintray.com/kotlin/kotlinx.coroutines" } }