mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 11:24:56 -04:00
network: set chunk packets to lower priority
This commit is contained in:
parent
f2f7c9f371
commit
f313efe214
@ -54,7 +54,7 @@ class ClientPacketHandler(
|
||||
|
||||
override fun channelRead0(context: ChannelHandlerContext, queued: QueuedS2CP<*>) {
|
||||
if (queued.type.threadSafe && DefaultThreadPool.queueSize <= DefaultThreadPool.threadCount) { // only handle async when thread pool not busy
|
||||
val runnable = ThreadPoolRunnable(priority = ThreadPool.Priorities.HIGH)
|
||||
val runnable = ThreadPoolRunnable(priority = if (queued.type.lowPriority) ThreadPool.Priorities.HIGH else ThreadPool.Priorities.HIGHER)
|
||||
runnable.runnable = Runnable { tryHandle(context, queued.type, queued.packet);handlers -= runnable }
|
||||
handlers += runnable
|
||||
DefaultThreadPool += runnable
|
||||
|
@ -16,4 +16,5 @@ package de.bixilon.minosoft.protocol.packets.factory
|
||||
interface AbstractPacketType {
|
||||
val direction: PacketDirection
|
||||
val threadSafe: Boolean
|
||||
val lowPriority: Boolean
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ class C2SPacketType(
|
||||
val clazz: Class<out C2SPacket>,
|
||||
val annotation: LoadPacket?,
|
||||
override val threadSafe: Boolean = annotation!!.threadSafe,
|
||||
override val lowPriority: Boolean = annotation!!.lowPriority,
|
||||
) : AbstractPacketType {
|
||||
override val direction = PacketDirection.CLIENT_TO_SERVER
|
||||
|
||||
@ -29,6 +30,6 @@ class C2SPacketType(
|
||||
}
|
||||
|
||||
companion object {
|
||||
val EMPTY = { C2SPacketType(ProtocolStates.HANDSHAKING, C2SPacket::class.java, null, false) }
|
||||
val EMPTY = { C2SPacketType(ProtocolStates.HANDSHAKING, C2SPacket::class.java, null, threadSafe = false, lowPriority = false) }
|
||||
}
|
||||
}
|
||||
|
@ -22,4 +22,5 @@ annotation class LoadPacket(
|
||||
val name: String = "",
|
||||
val threadSafe: Boolean = true,
|
||||
val parent: Boolean = false,
|
||||
val lowPriority: Boolean = false,
|
||||
)
|
||||
|
@ -19,13 +19,14 @@ import de.bixilon.minosoft.protocol.packets.factory.factories.PacketFactory
|
||||
import de.bixilon.minosoft.protocol.packets.s2c.S2CPacket
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolStates
|
||||
|
||||
class S2CPacketType(
|
||||
class S2CPacketType constructor(
|
||||
val state: ProtocolStates,
|
||||
val clazz: Class<out S2CPacket>,
|
||||
private val packetErrorHandler: PacketErrorHandler?,
|
||||
val annotation: LoadPacket?,
|
||||
val factory: PacketFactory? = null,
|
||||
override val threadSafe: Boolean = annotation!!.threadSafe,
|
||||
override val lowPriority: Boolean = annotation!!.lowPriority,
|
||||
) : AbstractPacketType, PacketErrorHandler {
|
||||
override val direction = PacketDirection.SERVER_TO_CLIENT
|
||||
|
||||
@ -40,6 +41,6 @@ class S2CPacketType(
|
||||
|
||||
|
||||
companion object {
|
||||
val EMPTY = { S2CPacketType(ProtocolStates.HANDSHAKING, S2CPacket::class.java, null, null, null, false) }
|
||||
val EMPTY = { S2CPacketType(ProtocolStates.HANDSHAKING, S2CPacket::class.java, null, null, null, threadSafe = false, lowPriority = false) }
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
import java.util.*
|
||||
|
||||
@LoadPacket
|
||||
@LoadPacket(lowPriority = true)
|
||||
class ChunkLightS2CP @JvmOverloads constructor(buffer: PlayInByteBuffer, chunkPositionGetter: () -> Vec2i = { Vec2i(buffer.readVarInt(), buffer.readVarInt()) }) : PlayS2CPacket {
|
||||
val chunkPosition: Vec2i = chunkPositionGetter()
|
||||
var trustEdges: Boolean = false
|
||||
|
@ -47,7 +47,7 @@ import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
import java.util.*
|
||||
|
||||
@LoadPacket
|
||||
@LoadPacket(lowPriority = true)
|
||||
class ChunkS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||
val chunkPosition: Vec2i
|
||||
val chunkData: ChunkData = ChunkData()
|
||||
|
Loading…
x
Reference in New Issue
Block a user