Micro optimizations regarding mattery network channel
This commit is contained in:
parent
dd2dab37a7
commit
6fbdb04ee4
@ -23,6 +23,7 @@ import java.math.BigInteger
|
||||
import java.util.Optional
|
||||
import java.util.concurrent.CompletableFuture
|
||||
import java.util.concurrent.ConcurrentLinkedDeque
|
||||
import java.util.concurrent.ConcurrentLinkedQueue
|
||||
import java.util.concurrent.locks.LockSupport
|
||||
import java.util.function.BiConsumer
|
||||
import java.util.function.Supplier
|
||||
@ -127,7 +128,7 @@ abstract class MatteryNetworkChannel(val version: String, val name: String) {
|
||||
private val logger = LogManager.getLogger()
|
||||
private var thread: Thread? = null
|
||||
|
||||
private val queue = ConcurrentLinkedDeque<Task>()
|
||||
private val queue = ConcurrentLinkedQueue<Task>()
|
||||
|
||||
@Volatile
|
||||
private var interrupt = false
|
||||
@ -143,7 +144,7 @@ abstract class MatteryNetworkChannel(val version: String, val name: String) {
|
||||
*/
|
||||
private fun run() {
|
||||
while (!interrupt) {
|
||||
val task = queue.pollFirst()
|
||||
val task = queue.poll()
|
||||
|
||||
if (task == null) {
|
||||
LockSupport.park()
|
||||
@ -160,7 +161,9 @@ abstract class MatteryNetworkChannel(val version: String, val name: String) {
|
||||
}
|
||||
|
||||
internal fun onServerPostTick() {
|
||||
LockSupport.unpark(thread)
|
||||
if (queue.isNotEmpty()) {
|
||||
LockSupport.unpark(thread)
|
||||
}
|
||||
}
|
||||
|
||||
internal fun onServerStarting() {
|
||||
|
Loading…
Reference in New Issue
Block a user