mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
[fleet] reformat, dead code
GitOrigin-RevId: 11175e0ad26c8d37505e087eda48133c89c8e89e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
5c53a163d6
commit
137ee8f6af
@@ -18,17 +18,21 @@ enum class EndpointKind {
|
||||
}
|
||||
|
||||
interface RequestDispatcher {
|
||||
suspend fun handleConnection(route: UID,
|
||||
endpoint: EndpointKind,
|
||||
presentableName: String? = null,
|
||||
send: SendChannel<TransportMessage>,
|
||||
receive: ReceiveChannel<TransportMessage>)
|
||||
suspend fun handleConnection(
|
||||
route: UID,
|
||||
endpoint: EndpointKind,
|
||||
presentableName: String? = null,
|
||||
send: SendChannel<TransportMessage>,
|
||||
receive: ReceiveChannel<TransportMessage>,
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun RequestDispatcher.serveRpc(route: UID,
|
||||
json: () -> Serialization,
|
||||
services: RpcServiceLocator,
|
||||
interceptor: RpcExecutorMiddleware = RpcExecutorMiddleware) {
|
||||
suspend fun RequestDispatcher.serveRpc(
|
||||
route: UID,
|
||||
json: () -> Serialization,
|
||||
services: RpcServiceLocator,
|
||||
interceptor: RpcExecutorMiddleware = RpcExecutorMiddleware,
|
||||
) {
|
||||
val dispatcher = this
|
||||
spannedScope("serveRpc") {
|
||||
val (dispatcherSend, executorReceive) = channels<TransportMessage>(Channel.BUFFERED)
|
||||
@@ -49,30 +53,3 @@ suspend fun RequestDispatcher.serveRpc(route: UID,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private data class Handle<out T>(private val deferred: Deferred<T>, private val job: Job) {
|
||||
suspend fun await(): T = deferred.await()
|
||||
suspend fun join(): Unit = job.join()
|
||||
fun cancel(cause: CancellationException?): Unit = job.cancel(cause)
|
||||
}
|
||||
|
||||
private fun <T> CoroutineScope.handle(body: suspend CoroutineScope.(suspend (T) -> Unit) -> Unit): Handle<T> {
|
||||
val deferred = CompletableDeferred<T>()
|
||||
val job = launch(start = CoroutineStart.ATOMIC) {
|
||||
body { t ->
|
||||
check(deferred.complete(t)) { "Subsequent invocations make no sense" }
|
||||
awaitCancellation()
|
||||
}
|
||||
}.apply {
|
||||
invokeOnCompletion { cause ->
|
||||
if (cause != null) {
|
||||
deferred.completeExceptionally(cause)
|
||||
}
|
||||
else {
|
||||
deferred.completeExceptionally(RuntimeException("job has finished"))
|
||||
}
|
||||
}
|
||||
}
|
||||
return Handle(deferred, job)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user