Code cleanup
This commit is contained in:
parent
9e20a20bbb
commit
7ac284bc1b
|
@ -47,7 +47,7 @@ internal class EventPoller {
|
|||
val eventLogger = KotlinLogging.logger(EventPoller::class.java.simpleName)
|
||||
|
||||
|
||||
private val pollDispatcher = Executors.newSingleThreadExecutor(
|
||||
private val pollExecutor = Executors.newSingleThreadExecutor(
|
||||
NamedThreadFactory("Poll Dispatcher", Configuration.networkThreadGroup, true)
|
||||
)
|
||||
}
|
||||
|
@ -95,10 +95,10 @@ internal class EventPoller {
|
|||
shutdownLatch = CountDownLatch(1)
|
||||
pollStrategy = config.pollIdleStrategy
|
||||
|
||||
pollDispatcher.submit(Runnable {
|
||||
pollExecutor.submit {
|
||||
val pollIdleStrategy = pollStrategy
|
||||
var pollCount = 0
|
||||
threadId = Thread.currentThread().id
|
||||
threadId = Thread.currentThread().id // only ever 1 thread!!!
|
||||
|
||||
pollIdleStrategy.reset()
|
||||
|
||||
|
@ -150,7 +150,7 @@ internal class EventPoller {
|
|||
}
|
||||
|
||||
shutdownLatch.countDown()
|
||||
})
|
||||
}
|
||||
} else {
|
||||
// we don't want to use .equals, because that also compares STATE, which for us is going to be different because we are cloned!
|
||||
// toString has the right info to compare types/config accurately
|
||||
|
@ -248,7 +248,7 @@ internal class EventPoller {
|
|||
configured = false
|
||||
|
||||
if (wasRunning) {
|
||||
pollDispatcher.awaitTermination(200, TimeUnit.MILLISECONDS)
|
||||
pollExecutor.awaitTermination(200, TimeUnit.MILLISECONDS)
|
||||
}
|
||||
logger.error { "Closed Network Event Poller: wasRunning=$wasRunning" }
|
||||
}
|
||||
|
|
|
@ -196,16 +196,17 @@ open class Connection(connectionParameters: ConnectionParams<*>) {
|
|||
* @return true if the message was successfully sent, false otherwise. Exceptions are caught and NOT rethrown!
|
||||
*/
|
||||
internal fun send(message: Any, abortEarly: Boolean): Boolean {
|
||||
// The handshake sessionId IS NOT globally unique
|
||||
logger.trace { "[$toString0] send: ${message.javaClass.simpleName} : $message" }
|
||||
if (logger.isTraceEnabled) {
|
||||
// The handshake sessionId IS NOT globally unique
|
||||
// don't automatically create the lambda when trace is disabled! Because this uses 'outside' scoped info, it's a new lambda each time!
|
||||
logger.trace { "[$toString0] send: ${message.javaClass.simpleName} : $message" }
|
||||
}
|
||||
return endPoint.write(message, publication, sendIdleStrategy, this@Connection, maxMessageSize, abortEarly)
|
||||
}
|
||||
|
||||
/**
|
||||
* Safely sends objects to a destination.
|
||||
*
|
||||
* NOTE: this is dispatched to the IO context!! (since network calls are IO/blocking calls)
|
||||
*
|
||||
* @return true if the message was successfully sent, false otherwise. Exceptions are caught and NOT rethrown!
|
||||
*/
|
||||
fun send(message: Any): Boolean {
|
||||
|
|
Loading…
Reference in New Issue