File tree 3 files changed +20
-18
lines changed
kotlinx-coroutines-core/common/src/selects
3 files changed +20
-18
lines changed Original file line number Diff line number Diff line change @@ -50,15 +50,16 @@ import kotlin.native.concurrent.*
50
50
* Use [yield] or [CoroutineScope.isActive] to periodically check for cancellation in tight loops if needed.
51
51
*/
52
52
public suspend inline fun <R > select (crossinline builder : SelectBuilder <R >.() -> Unit ): R {
53
- contract {
54
- callsInPlace(builder, InvocationKind .EXACTLY_ONCE )
55
- }
56
- return SelectImplementation <R >(coroutineContext).run {
57
- builder(this )
58
- // TAIL-CALL OPTIMIZATION: the only
59
- // suspend call is at the last position.
60
- doSelect()
61
- }
53
+ return selectOld(builder)
54
+ // contract {
55
+ // callsInPlace(builder, InvocationKind.EXACTLY_ONCE)
56
+ // }
57
+ // return SelectImplementation<R>(coroutineContext).run {
58
+ // builder(this)
59
+ // // TAIL-CALL OPTIMIZATION: the only
60
+ // // suspend call is at the last position.
61
+ // doSelect()
62
+ // }
62
63
}
63
64
64
65
/* *
Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ internal class UnbiasedSelectBuilderImpl<R>(
73
73
}
74
74
75
75
// This is the old version of `select`. It should work to guarantee binary compatibility.
76
- internal suspend inline fun <R > selectOld (crossinline builder : SelectBuilder <R >.() -> Unit ): R {
76
+ public suspend inline fun <R > selectOld (crossinline builder : SelectBuilder <R >.() -> Unit ): R {
77
77
return suspendCoroutineUninterceptedOrReturn { uCont ->
78
78
val scope = SelectBuilderImpl (uCont)
79
79
try {
@@ -86,7 +86,7 @@ internal suspend inline fun <R> selectOld(crossinline builder: SelectBuilder<R>.
86
86
}
87
87
88
88
// This is the old version of `selectUnbiased`. It should work to guarantee binary compatibility.
89
- internal suspend inline fun <R > selectUnbiasedOld (crossinline builder : SelectBuilder <R >.() -> Unit ): R =
89
+ public suspend inline fun <R > selectUnbiasedOld (crossinline builder : SelectBuilder <R >.() -> Unit ): R =
90
90
suspendCoroutineUninterceptedOrReturn { uCont ->
91
91
val scope = UnbiasedSelectBuilderImpl (uCont)
92
92
try {
Original file line number Diff line number Diff line change @@ -19,13 +19,14 @@ import kotlin.coroutines.*
19
19
* See [select] function description for all the other details.
20
20
*/
21
21
public suspend inline fun <R > selectUnbiased (crossinline builder : SelectBuilder <R >.() -> Unit ): R {
22
- contract {
23
- callsInPlace(builder, InvocationKind .EXACTLY_ONCE )
24
- }
25
- return UnbiasedSelectImplementation <R >(coroutineContext).run {
26
- builder(this )
27
- doSelect()
28
- }
22
+ return selectUnbiasedOld(builder)
23
+ // contract {
24
+ // callsInPlace(builder, InvocationKind.EXACTLY_ONCE)
25
+ // }
26
+ // return UnbiasedSelectImplementation<R>(coroutineContext).run {
27
+ // builder(this)
28
+ // doSelect()
29
+ // }
29
30
}
30
31
31
32
/* *
You can’t perform that action at this time.
0 commit comments