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 66
77package kotlinx.rpc.grpc
88
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.*
1310
1411/* *
1512 * Same as [ManagedChannel], but is platform-exposed.
@@ -31,7 +28,6 @@ internal class NativeManagedChannelBuilder(
3128 private var credentials: GrpcCredentials ? = null
3229
3330 override fun usePlaintext (): NativeManagedChannelBuilder {
34- check(credentials == null ) { " Credentials already set" }
3531 credentials = GrpcInsecureCredentials ()
3632 return this
3733 }
@@ -46,7 +42,7 @@ internal class NativeManagedChannelBuilder(
4642}
4743
4844internal 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" ) }
5046 return buildChannel()
5147}
5248
Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ internal class CompletionQueue {
5252
5353 // if the shutdown() was called with forceShutdown = true,
5454 // 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 )
5656
5757 // internal as it must be accessible from the SHUTDOWN_CB,
5858 // but it shouldn't be used from outside this file.
@@ -109,7 +109,7 @@ internal class CompletionQueue {
109109 return BatchResult .CQShutdown
110110 }
111111
112- if (forceShutdown || _state .value == State .CLOSED ) {
112+ if (forceShutdown.value || _state .value == State .CLOSED ) {
113113 // if the queue is either closed or in the process of a FORCE shutdown,
114114 // new batches will instantly fail.
115115 deleteCbTag(tag)
@@ -139,7 +139,7 @@ internal class CompletionQueue {
139139 */
140140 fun shutdown (force : Boolean = false): CallbackFuture <Unit > {
141141 if (force) {
142- forceShutdown = true
142+ forceShutdown.value = true
143143 }
144144 if (! _state .compareAndSet(State .OPEN , State .SHUTTING_DOWN )) {
145145 // 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 {
4747internal fun CPointer<grpc_byte_buffer>.toKotlin (): Buffer = memScoped {
4848 val reader = alloc< grpc_byte_buffer_reader> ()
4949 check(grpc_byte_buffer_reader_init(reader.ptr, this @toKotlin) == 1 )
50- { " Failed to initialized byte buffer." }
50+ { internalError( " Failed to initialized byte buffer." ) }
5151
5252 val out = Buffer ()
5353 val slice = alloc< grpc_slice> ()
You can’t perform that action at this time.
0 commit comments