mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-13 01:16:46 -04:00
network: never handle low priority packets on network thread
Its not blocked by chunk packets anymore.
This commit is contained in:
parent
8ae3886f5b
commit
8bc8e0bc5f
@ -16,7 +16,7 @@ package de.bixilon.minosoft.protocol.network.network.client.netty.pipeline
|
||||
import de.bixilon.kutil.cast.CastUtil.nullCast
|
||||
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
|
||||
import de.bixilon.kutil.concurrent.pool.ThreadPool
|
||||
import de.bixilon.kutil.concurrent.pool.runnable.SimplePoolRunnable
|
||||
import de.bixilon.kutil.concurrent.pool.runnable.ForcePooledRunnable
|
||||
import de.bixilon.minosoft.config.profile.profiles.other.OtherProfileManager
|
||||
import de.bixilon.minosoft.modding.event.events.PacketReceiveEvent
|
||||
import de.bixilon.minosoft.protocol.network.connection.Connection
|
||||
@ -39,9 +39,8 @@ class ClientPacketHandler(
|
||||
private val connection: Connection = client.connection
|
||||
|
||||
override fun channelRead0(context: ChannelHandlerContext, queued: QueuedS2CP<*>) {
|
||||
if (queued.type.threadSafe && (DefaultThreadPool.queueSize < DefaultThreadPool.threadCount - 1 || queued.type.lowPriority)) { // only handle async when thread pool not busy
|
||||
val runnable = SimplePoolRunnable(priority = if (queued.type.lowPriority) ThreadPool.Priorities.NORMAL else ThreadPool.Priorities.HIGH)
|
||||
runnable.runnable = Runnable { tryHandle(context, queued.type, queued.packet) }
|
||||
if (queued.type.threadSafe && (queued.type.lowPriority || DefaultThreadPool.queueSize < DefaultThreadPool.threadCount - 1)) { // only handle async when thread pool not busy
|
||||
val runnable = ForcePooledRunnable(priority = if (queued.type.lowPriority) ThreadPool.Priorities.NORMAL else ThreadPool.Priorities.HIGH) { tryHandle(context, queued.type, queued.packet) }
|
||||
DefaultThreadPool += runnable
|
||||
} else {
|
||||
tryHandle(context, queued.type, queued.packet)
|
||||
|
Loading…
x
Reference in New Issue
Block a user