File tree Expand file tree Collapse file tree 3 files changed +6
-10
lines changed
grpc/grpc-core/src/nativeMain/kotlin/kotlinx/rpc/grpc Expand file tree Collapse file tree 3 files changed +6
-10
lines changed Original file line number Diff line number Diff line change 6
6
7
7
package kotlinx.rpc.grpc
8
8
9
- import kotlinx.rpc.grpc.internal.GrpcChannel
10
- import kotlinx.rpc.grpc.internal.GrpcCredentials
11
- import kotlinx.rpc.grpc.internal.GrpcInsecureCredentials
12
- import kotlinx.rpc.grpc.internal.NativeManagedChannel
9
+ import kotlinx.rpc.grpc.internal.*
13
10
14
11
/* *
15
12
* Same as [ManagedChannel], but is platform-exposed.
@@ -31,7 +28,6 @@ internal class NativeManagedChannelBuilder(
31
28
private var credentials: GrpcCredentials ? = null
32
29
33
30
override fun usePlaintext (): NativeManagedChannelBuilder {
34
- check(credentials == null ) { " Credentials already set" }
35
31
credentials = GrpcInsecureCredentials ()
36
32
return this
37
33
}
@@ -46,7 +42,7 @@ internal class NativeManagedChannelBuilder(
46
42
}
47
43
48
44
internal actual fun ManagedChannelBuilder <* >.buildChannel (): ManagedChannel {
49
- check(this is NativeManagedChannelBuilder ) { " Wrong builder type, expected NativeManagedChannelBuilder" }
45
+ check(this is NativeManagedChannelBuilder ) { internalError( " Wrong builder type, expected NativeManagedChannelBuilder" ) }
50
46
return buildChannel()
51
47
}
52
48
Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ internal class CompletionQueue {
52
52
53
53
// if the shutdown() was called with forceShutdown = true,
54
54
// it will reject all new batches and wait for all current ones to finish.
55
- private var forceShutdown = false
55
+ private val forceShutdown = atomic( false )
56
56
57
57
// internal as it must be accessible from the SHUTDOWN_CB,
58
58
// but it shouldn't be used from outside this file.
@@ -109,7 +109,7 @@ internal class CompletionQueue {
109
109
return BatchResult .CQShutdown
110
110
}
111
111
112
- if (forceShutdown || _state .value == State .CLOSED ) {
112
+ if (forceShutdown.value || _state .value == State .CLOSED ) {
113
113
// if the queue is either closed or in the process of a FORCE shutdown,
114
114
// new batches will instantly fail.
115
115
deleteCbTag(tag)
@@ -139,7 +139,7 @@ internal class CompletionQueue {
139
139
*/
140
140
fun shutdown (force : Boolean = false): CallbackFuture <Unit > {
141
141
if (force) {
142
- forceShutdown = true
142
+ forceShutdown.value = true
143
143
}
144
144
if (! _state .compareAndSet(State .OPEN , State .SHUTTING_DOWN )) {
145
145
// the first call to shutdown() makes transition and to SHUTTING_DOWN and
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ internal fun grpc_slice.toByteArray(): ByteArray = memScoped {
47
47
internal fun CPointer<grpc_byte_buffer>.toKotlin (): Buffer = memScoped {
48
48
val reader = alloc< grpc_byte_buffer_reader> ()
49
49
check(grpc_byte_buffer_reader_init(reader.ptr, this @toKotlin) == 1 )
50
- { " Failed to initialized byte buffer." }
50
+ { internalError( " Failed to initialized byte buffer." ) }
51
51
52
52
val out = Buffer ()
53
53
val slice = alloc< grpc_slice> ()
You can’t perform that action at this time.
0 commit comments