Skip to content

Commit f8bf336

Browse files
author
frederic.montariol
committed
comment all expect and actual impl for kotlinx coroutines, because it will be available as a common module (see Kotlin/kotlinx.coroutines#33) : kotlinx-coroutines and kotlinx-coroutines-reactive will be available as multiplatform projects (common + JS and JVM impl)
1 parent 6bbd9ca commit f8bf336

File tree

4 files changed

+114
-135
lines changed

4 files changed

+114
-135
lines changed
Lines changed: 55 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,59 @@
1-
package reactivity.experimental
2-
3-
import kotlin.coroutines.experimental.CoroutineContext
4-
5-
// coroutine contexts
6-
expect val DefaultDispatcher: CoroutineContext
7-
8-
// general
9-
expect interface CoroutineScope {
10-
val context: CoroutineContext
11-
}
12-
//expect interface SendChannel<E> {
1+
//package reactivity.experimental
2+
//
3+
//// No needed : https://github.com/Kotlin/kotlinx.coroutines/issues/33
4+
//// Kotlinx-coroutines will be available as multiplatform projects (common + JS and JVM impl)
5+
//
6+
//import kotlin.coroutines.experimental.CoroutineContext
7+
//
8+
//// coroutine contexts
9+
//expect val DefaultDispatcher: CoroutineContext
10+
//
11+
//// general
12+
//expect interface CoroutineScope {
13+
// val context: CoroutineContext
14+
//}
15+
//expect interface ProducerScope<in E> {
1316
// suspend fun send(element: E)
14-
// fun close(cause: Throwable?): Boolean
17+
// val context: CoroutineContext
18+
//}
19+
//expect interface Job : CoroutineContext.Element
20+
//expect fun launch(
21+
// context: CoroutineContext,
22+
// block: suspend CoroutineScope.() -> Unit
23+
//): Job
24+
//
25+
//// selects
26+
//expect interface SelectClause1<out Q>
27+
//expect interface SelectBuilder<in R> {
28+
// operator fun <Q> SelectClause1<Q>.invoke(block: suspend (Q) -> R)
29+
//}
30+
//expect suspend fun whileSelect(builder: SelectBuilder<Boolean>.() -> Unit)
31+
//
32+
//// channels
33+
//expect interface ChannelIterator<out E> {
34+
// suspend operator fun hasNext(): Boolean
35+
// suspend operator fun next(): E
36+
//}
37+
//expect interface ReceiveChannel<out E> {
38+
// val onReceive: SelectClause1<E>
39+
// operator fun iterator() : ChannelIterator<E>
40+
//}
41+
//expect open class LinkedListChannel<E>() {
42+
// // from superclass AbstractSendChannel
43+
// protected open fun afterClose(cause: Throwable?)
44+
// open fun close(cause: Throwable?): Boolean
1545
// fun offer(element: E): Boolean
46+
// // from superclass AbstractChannel
47+
// fun iterator(): ChannelIterator<E>
48+
// val onReceive: SelectClause1<E>
49+
//}
50+
//expect interface SubscriptionReceiveChannel<out T> : Closeable {
51+
// operator fun iterator(): ChannelIterator<T>
52+
// val onReceive: SelectClause1<T>
1653
//}
17-
expect interface ProducerScope<in E> {
18-
suspend fun send(element: E)
19-
val context: CoroutineContext
20-
}
21-
expect interface Job : CoroutineContext.Element
22-
expect fun launch(
23-
context: CoroutineContext,
24-
block: suspend CoroutineScope.() -> Unit
25-
): Job
26-
27-
// selects
28-
expect interface SelectClause1<out Q>
29-
expect interface SelectBuilder<in R> {
30-
operator fun <Q> SelectClause1<Q>.invoke(block: suspend (Q) -> R)
31-
}
32-
expect suspend fun whileSelect(builder: SelectBuilder<Boolean>.() -> Unit)
33-
34-
// channels
35-
expect interface ChannelIterator<out E> {
36-
suspend operator fun hasNext(): Boolean
37-
suspend operator fun next(): E
38-
}
39-
expect interface ReceiveChannel<out E> {
40-
val onReceive: SelectClause1<E>
41-
operator fun iterator() : ChannelIterator<E>
42-
}
43-
expect open class LinkedListChannel<E>() {
44-
// from superclass AbstractSendChannel
45-
protected open fun afterClose(cause: Throwable?)
46-
open fun close(cause: Throwable?): Boolean
54+
//expect inline suspend fun <E> ReceiveChannel<E>.consumeEach(action: (E) -> Unit)
55+
//expect interface Channel<E> : ReceiveChannel<E> {
4756
// suspend fun send(element: E)
48-
fun offer(element: E): Boolean
49-
// from superclass AbstractChannel
50-
fun iterator(): ChannelIterator<E>
51-
val onReceive: SelectClause1<E>
52-
}
53-
expect interface SubscriptionReceiveChannel<out T> : Closeable {
54-
operator fun iterator(): ChannelIterator<T>
55-
val onReceive: SelectClause1<T>
56-
}
57-
expect inline suspend fun <E> ReceiveChannel<E>.consumeEach(action: (E) -> Unit)
58-
expect interface Channel<E> : ReceiveChannel<E> {
59-
suspend fun send(element: E)
60-
fun close(cause: Throwable?): Boolean
61-
}
62-
expect fun <E> Channel(capacity: Int): Channel<E>
57+
// fun close(cause: Throwable?): Boolean
58+
//}
59+
//expect fun <E> Channel(capacity: Int): Channel<E>
Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
package reactivity.experimental
2-
3-
import kotlin.coroutines.experimental.CoroutineContext
4-
5-
expect inline suspend fun <T> Publisher<T>.consumeEach(action: (T) -> Unit)
6-
expect fun <T> publish(context: CoroutineContext, block: suspend ProducerScope<T>.() -> Unit): Publisher<T>
7-
expect fun <T> Publisher<T>.openSubscription(): SubscriptionReceiveChannel<T>
8-
expect suspend fun <T> Publisher<T>.awaitSingle(): T
9-
expect fun <T> ReceiveChannel<T>.asPublisher(context: CoroutineContext): Publisher<T>
1+
//package reactivity.experimental
2+
//
3+
//// No needed : https://github.com/Kotlin/kotlinx.coroutines/issues/33
4+
//// Kotlinx-coroutines-reactive will be available as multiplatform projects (common + JS and JVM impl)
5+
//
6+
//import kotlin.coroutines.experimental.CoroutineContext
7+
//
8+
//expect inline suspend fun <T> Publisher<T>.consumeEach(action: (T) -> Unit)
9+
//expect fun <T> publish(context: CoroutineContext, block: suspend ProducerScope<T>.() -> Unit): Publisher<T>
10+
//expect fun <T> Publisher<T>.openSubscription(): SubscriptionReceiveChannel<T>
11+
//expect suspend fun <T> Publisher<T>.awaitSingle(): T
12+
//expect fun <T> ReceiveChannel<T>.asPublisher(context: CoroutineContext): Publisher<T>
Lines changed: 34 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,34 @@
1-
package reactivity.experimental
2-
3-
import kotlinx.coroutines.experimental.CoroutineStart
4-
import kotlinx.coroutines.experimental.channels.consumeEach
5-
import kotlin.coroutines.experimental.CoroutineContext
6-
7-
// coroutine contexts
8-
actual val DefaultDispatcher: CoroutineContext = kotlinx.coroutines.experimental.DefaultDispatcher
9-
10-
// general
11-
actual typealias CoroutineScope = kotlinx.coroutines.experimental.CoroutineScope
12-
// FIXME https://github.com/JetBrains/kotlin/blob/master/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java
13-
// FIXME MAP.put(ACTUAL_TYPE_ALIAS_TO_CLASS_WITH_DECLARATION_SITE_VARIANCE, "Aliased class should not have type parameters with declaration-site variance");
14-
// FIXME remove this added Interface when declarative-site variance will be supported for alias
15-
//interface MyProducerScope<E> : kotlinx.coroutines.experimental.channels.ProducerScope<E>
16-
actual typealias ProducerScope<E> = kotlinx.coroutines.experimental.channels.ProducerScope<E>
17-
actual typealias Job = kotlinx.coroutines.experimental.Job
18-
actual fun launch(
19-
context: CoroutineContext,
20-
block: suspend CoroutineScope.() -> Unit
21-
): Job = kotlinx.coroutines.experimental.launch(context, CoroutineStart.DEFAULT, block)
22-
23-
// selects
24-
// remove this added Interface when declarative-site variance will be supported for alias
25-
//interface MySelectClause1<Q> : kotlinx.coroutines.experimental.selects.SelectClause1<Q>
26-
actual typealias SelectClause1<Q> = kotlinx.coroutines.experimental.selects.SelectClause1<Q>
27-
// FIXME remove this added Interface when declarative-site variance will be supported for alias
28-
//interface MySelectBuilder<R> : kotlinx.coroutines.experimental.selects.SelectBuilder<R>
29-
actual typealias SelectBuilder<R> = kotlinx.coroutines.experimental.selects.SelectBuilder<R>
30-
actual suspend fun whileSelect(builder: SelectBuilder<Boolean>.() -> Unit)
31-
= kotlinx.coroutines.experimental.selects.whileSelect(builder)
32-
33-
// channels
34-
// FIXME remove this added Interface when declarative-site variance will be supported for alias
35-
//interface MyChannelIterator<E> : kotlinx.coroutines.experimental.channels.ChannelIterator<E>
36-
actual typealias ChannelIterator<E> = kotlinx.coroutines.experimental.channels.ChannelIterator<E>
37-
//actual interface ChannelIterator<E> {
38-
// actual suspend operator fun hasNext(): Boolean
39-
// actual suspend operator fun next(): E
40-
//}
41-
// FIXME remove this added Interface when declarative-site variance will be supported for alias
42-
//interface MyReceiveChannel<E> : kotlinx.coroutines.experimental.channels.ReceiveChannel<E>// {
43-
// override operator fun iterator(): ChannelIterator<E>
44-
// override val onReceive: SelectClause1<E>
45-
//}
46-
actual typealias ReceiveChannel<E> = kotlinx.coroutines.experimental.channels.ReceiveChannel<E>
47-
//open class MyLinkedListChannel<E> : kotlinx.coroutines.experimental.channels.LinkedListChannel<E>()
48-
49-
actual typealias LinkedListChannel<E> = kotlinx.coroutines.experimental.channels.LinkedListChannel<E>
50-
actual typealias SubscriptionReceiveChannel<T> = kotlinx.coroutines.experimental.channels.SubscriptionReceiveChannel<T>
51-
52-
actual inline suspend fun <E> ReceiveChannel<E>.consumeEach(action: (E) -> Unit) = this@consumeEach.consumeEach(action)
53-
actual typealias Channel<E> = kotlinx.coroutines.experimental.channels.Channel<E>
54-
55-
actual fun <E> Channel(capacity: Int): Channel<E> = kotlinx.coroutines.experimental.channels.Channel(capacity)
1+
//package reactivity.experimental
2+
//
3+
//import kotlinx.coroutines.experimental.CoroutineStart
4+
//import kotlinx.coroutines.experimental.channels.consumeEach
5+
//import kotlin.coroutines.experimental.CoroutineContext
6+
//
7+
//// coroutine contexts
8+
//actual val DefaultDispatcher: CoroutineContext = kotlinx.coroutines.experimental.DefaultDispatcher
9+
//
10+
//// general
11+
//actual typealias CoroutineScope = kotlinx.coroutines.experimental.CoroutineScope
12+
//// FIXME https://github.com/JetBrains/kotlin/blob/master/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java
13+
//// FIXME MAP.put(ACTUAL_TYPE_ALIAS_TO_CLASS_WITH_DECLARATION_SITE_VARIANCE, "Aliased class should not have type parameters with declaration-site variance");
14+
//actual typealias ProducerScope<E> = kotlinx.coroutines.experimental.channels.ProducerScope<E>
15+
//actual typealias Job = kotlinx.coroutines.experimental.Job
16+
//actual fun launch(
17+
// context: CoroutineContext,
18+
// block: suspend CoroutineScope.() -> Unit
19+
//): Job = kotlinx.coroutines.experimental.launch(context, CoroutineStart.DEFAULT, block)
20+
//
21+
//// selects
22+
//actual typealias SelectClause1<Q> = kotlinx.coroutines.experimental.selects.SelectClause1<Q>
23+
//actual typealias SelectBuilder<R> = kotlinx.coroutines.experimental.selects.SelectBuilder<R>
24+
//actual suspend fun whileSelect(builder: SelectBuilder<Boolean>.() -> Unit)
25+
// = kotlinx.coroutines.experimental.selects.whileSelect(builder)
26+
//
27+
//// channels
28+
//actual typealias ChannelIterator<E> = kotlinx.coroutines.experimental.channels.ChannelIterator<E>
29+
//actual typealias ReceiveChannel<E> = kotlinx.coroutines.experimental.channels.ReceiveChannel<E>
30+
//actual typealias LinkedListChannel<E> = kotlinx.coroutines.experimental.channels.LinkedListChannel<E>
31+
//actual typealias SubscriptionReceiveChannel<T> = kotlinx.coroutines.experimental.channels.SubscriptionReceiveChannel<T>
32+
//actual inline suspend fun <E> ReceiveChannel<E>.consumeEach(action: (E) -> Unit) = [email protected](action)
33+
//actual typealias Channel<E> = kotlinx.coroutines.experimental.channels.Channel<E>
34+
//actual fun <E> Channel(capacity: Int): Channel<E> = kotlinx.coroutines.experimental.channels.Channel(capacity)
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
package reactivity.experimental
2-
3-
import kotlinx.coroutines.experimental.reactive.asPublisher
4-
import kotlinx.coroutines.experimental.reactive.awaitSingle
5-
import kotlinx.coroutines.experimental.reactive.consumeEach
6-
import kotlinx.coroutines.experimental.reactive.openSubscription
7-
import kotlin.coroutines.experimental.CoroutineContext
8-
9-
actual inline suspend fun <T> Publisher<T>.consumeEach(action: (T) -> Unit) = this@consumeEach.consumeEach(action)
10-
actual fun <T> publish(context: CoroutineContext, block: suspend ProducerScope<T>.() -> Unit): Publisher<T> = kotlinx.coroutines.experimental.reactive.publish(context, block)
11-
actual fun <T> Publisher<T>.openSubscription(): SubscriptionReceiveChannel<T> = this@openSubscription.openSubscription()
12-
actual suspend fun <T> Publisher<T>.awaitSingle(): T = this@awaitSingle.awaitSingle()
13-
actual fun <T> ReceiveChannel<T>.asPublisher(context: CoroutineContext): Publisher<T> = this@asPublisher.asPublisher(context)
1+
//package reactivity.experimental
2+
//
3+
//import kotlinx.coroutines.experimental.reactive.asPublisher
4+
//import kotlinx.coroutines.experimental.reactive.awaitSingle
5+
//import kotlinx.coroutines.experimental.reactive.consumeEach
6+
//import kotlinx.coroutines.experimental.reactive.openSubscription
7+
//import kotlin.coroutines.experimental.CoroutineContext
8+
//
9+
//actual inline suspend fun <T> Publisher<T>.consumeEach(action: (T) -> Unit) = [email protected](action)
10+
//actual fun <T> publish(context: CoroutineContext, block: suspend ProducerScope<T>.() -> Unit): Publisher<T> = kotlinx.coroutines.experimental.reactive.publish(context, block)
11+
//actual fun <T> Publisher<T>.openSubscription(): SubscriptionReceiveChannel<T> = [email protected]()
12+
//actual suspend fun <T> Publisher<T>.awaitSingle(): T = [email protected]()
13+
//actual fun <T> ReceiveChannel<T>.asPublisher(context: CoroutineContext): Publisher<T> = [email protected](context)

0 commit comments

Comments
 (0)