updated API

This commit is contained in:
Robinson 2023-03-02 19:44:06 +01:00
parent 96b5bcf905
commit 062b8a76ae
No known key found for this signature in database
GPG Key ID: 8E7DB78588BD6F5C
4 changed files with 8 additions and 9 deletions

View File

@ -82,7 +82,7 @@ internal class ServerHandshake<CONNECTION : Connection>(
// note: CANNOT be called in action dispatch. ALWAYS ON SAME THREAD. ONLY RESPONSES ARE ON ACTION DISPATCH!
private fun validateMessageTypeAndDoPending(
server: Server<CONNECTION>,
eventDispatch: CoroutineScope,
eventDispatch: EventDispatcher,
handshakePublication: Publication,
message: HandshakeMessage,
logger: KLogger

View File

@ -20,8 +20,8 @@
package dorkbox.network.ping
import dorkbox.network.connection.Connection
import dorkbox.network.connection.EventDispatcher
import dorkbox.network.rmi.ResponseManager
import kotlinx.coroutines.CoroutineScope
import mu.KLogger
import java.util.concurrent.*
@ -61,7 +61,7 @@ internal class PingManager<CONNECTION : Connection> {
internal suspend fun ping(
connection: Connection,
pingTimeoutSeconds: Int,
eventDispatch: CoroutineScope,
eventDispatch: EventDispatcher,
responseManager: ResponseManager,
logger: KLogger,
function: suspend Ping.() -> Unit

View File

@ -16,12 +16,11 @@
package dorkbox.network.rmi
import dorkbox.network.connection.Connection
import dorkbox.network.connection.EventDispatcher
import kotlinx.atomicfu.atomic
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.ClosedSendChannelException
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import mu.KLogger
import mu.KotlinLogging
@ -184,7 +183,7 @@ internal class ResponseManager(maxValuesInCache: Int = 65535, minimumValue: Int
/**
* Cancels the RMI request in the given timeout, the callback is executed inside the read lock
*/
fun cancelRequest(eventDispatch: CoroutineScope, timeoutMillis: Long, id: Int, logger: KLogger, onCancelled: ResponseWaiter.() -> Unit) {
fun cancelRequest(eventDispatch: EventDispatcher, timeoutMillis: Long, id: Int, logger: KLogger, onCancelled: ResponseWaiter.() -> Unit) {
eventDispatch.launch {
delay(timeoutMillis) // this will always wait. if this job is cancelled, this will immediately stop waiting
@ -209,7 +208,7 @@ internal class ResponseManager(maxValuesInCache: Int = 65535, minimumValue: Int
* @return the result (can be null) or timeout exception
*/
suspend fun waitForReply(
eventDispatch: CoroutineScope,
eventDispatch: EventDispatcher,
responseWaiter: ResponseWaiter,
timeoutMillis: Long,
logger: KLogger,

View File

@ -17,8 +17,8 @@ package dorkbox.network.rmi
import dorkbox.network.connection.Connection
import dorkbox.network.connection.EndPoint
import dorkbox.network.connection.EventDispatcher
import dorkbox.network.rmi.messages.MethodRequest
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.asContextElement
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
@ -181,7 +181,7 @@ internal class RmiClient(val isGlobal: Boolean,
@Volatile private var enableEquals = false
// if we are ASYNC, then this method immediately returns
private suspend fun sendRequest(isAsync: Boolean, eventDispatch: CoroutineScope, invokeMethod: MethodRequest, logger: KLogger): Any? {
private suspend fun sendRequest(isAsync: Boolean, eventDispatch: EventDispatcher, invokeMethod: MethodRequest, logger: KLogger): Any? {
// there is a STRANGE problem, where if we DO NOT respond/reply to method invocation, and immediate invoke multiple methods --
// the "server" side can have out-of-order method invocation. There are 2 ways to solve this
// 1) make the "server" side single threaded