parent
ffb7c7b5ae
commit
3535cf95f7
77
src/main/kotlin/ru/dbotthepony/mc/otm/SystemTime.kt
Normal file
77
src/main/kotlin/ru/dbotthepony/mc/otm/SystemTime.kt
Normal file
@ -0,0 +1,77 @@
|
||||
package ru.dbotthepony.mc.otm
|
||||
|
||||
import net.minecraft.util.TimeSource
|
||||
import ru.dbotthepony.mc.otm.core.formatTickDuration
|
||||
import java.util.function.LongSupplier
|
||||
|
||||
/**
|
||||
* just to avoid origin in future
|
||||
*/
|
||||
|
||||
val systemTime = SystemTime()
|
||||
|
||||
/**
|
||||
* nanoseconds elapsed
|
||||
*/
|
||||
val nanoTime get() = systemTime.nanos
|
||||
|
||||
/**
|
||||
* microseconds elapsed
|
||||
*/
|
||||
val microTime get() = systemTime.micros
|
||||
|
||||
/**
|
||||
* milliseconds elapsed
|
||||
*/
|
||||
val milliTime get() = systemTime.millis
|
||||
|
||||
/**
|
||||
* seconds elapsed
|
||||
*/
|
||||
val secondTime get() = systemTime.seconds
|
||||
|
||||
val microTimeD get() = systemTime.microsD
|
||||
val milliTimeD get() = systemTime.millisD
|
||||
val secondTimeD get() = systemTime.secondsD
|
||||
|
||||
val microTimeF get() = systemTime.microsF
|
||||
val milliTimeF get() = systemTime.millisF
|
||||
val secondTimeF get() = systemTime.secondsF
|
||||
|
||||
/**
|
||||
* just to avoid origin in future
|
||||
*/
|
||||
class SystemTime : LongSupplier, TimeSource.NanoTimeSource {
|
||||
private val origin = System.nanoTime()
|
||||
|
||||
val nanos get() = System.nanoTime() - origin
|
||||
val micros get() = (System.nanoTime() - origin) / 1_000L
|
||||
val millis get() = (System.nanoTime() - origin) / 1_000_000L
|
||||
val seconds get() = (System.nanoTime() - origin) / 1_000_000_000L
|
||||
|
||||
val microsD get() = (System.nanoTime() - origin) / 1_000.0
|
||||
val millisD get() = (System.nanoTime() - origin) / 1_000_000.0
|
||||
val secondsD get() = (System.nanoTime() - origin) / 1_000_000_000.0
|
||||
|
||||
val microsF get() = (System.nanoTime() - origin) / 1_000f
|
||||
val millisF get() = (System.nanoTime() - origin) / 1_000_000f
|
||||
val secondsF get() = (System.nanoTime() - origin) / 1_000_000_000f
|
||||
|
||||
override fun getAsLong(): Long {
|
||||
return nanos
|
||||
}
|
||||
|
||||
fun formatted(longFormat: Boolean = true) = formatTickDuration((millis / 50L).toInt(), longFormat)
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
return other === this || other is SystemTime && other.origin == origin
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return origin.hashCode()
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "SystemTime[at ${origin}ns, ${secondsD}s elapsed]"
|
||||
}
|
||||
}
|
@ -24,6 +24,7 @@ import ru.dbotthepony.mc.otm.core.getCompoundList
|
||||
import ru.dbotthepony.mc.otm.core.nonEmpty
|
||||
import ru.dbotthepony.mc.otm.core.registryName
|
||||
import ru.dbotthepony.mc.otm.core.set
|
||||
import ru.dbotthepony.mc.otm.nanoTime
|
||||
import ru.dbotthepony.mc.otm.network.FieldSynchronizer
|
||||
import ru.dbotthepony.mc.otm.registry.MRegistry
|
||||
import ru.dbotthepony.mc.otm.triggers.AndroidResearchTrigger
|
||||
@ -347,7 +348,7 @@ class AndroidResearch(val type: AndroidResearchType, val capability: MatteryPlay
|
||||
}
|
||||
}
|
||||
|
||||
val chooseItem = tag.items[((System.nanoTime() / 300_000_000L).absoluteValue % tag.items.size).toInt()]
|
||||
val chooseItem = tag.items[((nanoTime / 300_000_000L).absoluteValue % tag.items.size).toInt()]
|
||||
val suffix = if (tag.items.size > 1) "_any" else ""
|
||||
|
||||
if (required > 0) {
|
||||
|
@ -9,7 +9,6 @@ import net.minecraft.client.renderer.LevelRenderer
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.core.Direction
|
||||
import net.minecraft.core.Vec3i
|
||||
import net.minecraft.nbt.CompoundTag
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import net.minecraft.sounds.SoundEvents
|
||||
@ -36,7 +35,6 @@ import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource
|
||||
import ru.dbotthepony.mc.otm.client.render.ResearchIcons
|
||||
import ru.dbotthepony.mc.otm.client.render.element
|
||||
import ru.dbotthepony.mc.otm.client.render.linesIgnoreZRenderType
|
||||
import ru.dbotthepony.mc.otm.core.ImmutableList
|
||||
import ru.dbotthepony.mc.otm.core.Vector
|
||||
import ru.dbotthepony.mc.otm.core.asVector
|
||||
import ru.dbotthepony.mc.otm.core.component1
|
||||
@ -44,17 +42,14 @@ import ru.dbotthepony.mc.otm.core.component2
|
||||
import ru.dbotthepony.mc.otm.core.component3
|
||||
import ru.dbotthepony.mc.otm.core.formatPower
|
||||
import ru.dbotthepony.mc.otm.core.genericPositions
|
||||
import ru.dbotthepony.mc.otm.core.minus
|
||||
import ru.dbotthepony.mc.otm.core.plus
|
||||
import ru.dbotthepony.mc.otm.core.set
|
||||
import ru.dbotthepony.mc.otm.core.shortestDistanceBetween
|
||||
import ru.dbotthepony.mc.otm.core.times
|
||||
import ru.dbotthepony.mc.otm.core.toDoubleVector
|
||||
import ru.dbotthepony.mc.otm.milliTime
|
||||
import ru.dbotthepony.mc.otm.registry.AndroidFeatures
|
||||
import ru.dbotthepony.mc.otm.registry.MNames
|
||||
import ru.dbotthepony.mc.otm.triggers.EnderTeleporterFallDeathTrigger
|
||||
import java.util.LinkedList
|
||||
import kotlin.math.roundToInt
|
||||
import java.util.*
|
||||
import kotlin.math.sin
|
||||
|
||||
class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiveFeature(AndroidFeatures.ENDER_TELEPORTER, capability) {
|
||||
@ -345,7 +340,7 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv
|
||||
poseStack.mulPose(Vector3f.YP.rotationDegrees(-camera.yRot))
|
||||
poseStack.mulPose(Vector3f.XP.rotationDegrees(camera.xRot))
|
||||
|
||||
val size = 1f + sin((System.nanoTime() / 1_000_000) / 250.0).toFloat() * 0.2f
|
||||
val size = 1f + sin(milliTime / 250.0).toFloat() * 0.2f
|
||||
val half = size / -2f
|
||||
|
||||
RenderSystem.disableDepthTest()
|
||||
|
@ -17,6 +17,7 @@ import ru.dbotthepony.mc.otm.client.render.TextAlign
|
||||
import ru.dbotthepony.mc.otm.client.render.drawAligned
|
||||
import ru.dbotthepony.mc.otm.client.render.drawArc
|
||||
import ru.dbotthepony.mc.otm.core.*
|
||||
import ru.dbotthepony.mc.otm.milliTimeD
|
||||
import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel
|
||||
import ru.dbotthepony.mc.otm.network.SwitchAndroidFeaturePacket
|
||||
import java.util.stream.Collectors
|
||||
@ -32,7 +33,7 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon
|
||||
private var selectedFeature: AndroidSwitchableFeature? = null
|
||||
private var lastSelectedFeature: AndroidSwitchableFeature? = null
|
||||
|
||||
private var lastRender: Long = System.nanoTime()
|
||||
private var lastRender = milliTimeD
|
||||
private var lastSelectedDegree: Double? = null
|
||||
private val lastSelectProgress = Object2FloatArrayMap<AndroidFeature>()
|
||||
private var lastSelectProgressGlobal = 0f
|
||||
@ -117,7 +118,7 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon
|
||||
.collect(Collectors.toList()) as MutableList<AndroidSwitchableFeature>
|
||||
|
||||
if (features.isEmpty()) {
|
||||
lastRender = System.nanoTime()
|
||||
lastRender = milliTimeD
|
||||
return
|
||||
}
|
||||
|
||||
@ -125,8 +126,8 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon
|
||||
return@sortWith a.type.registryName!!.compareTo(b.type.registryName!!)
|
||||
}
|
||||
|
||||
val delta = (System.nanoTime() - lastRender) / 1_000_000.0
|
||||
lastRender = System.nanoTime()
|
||||
val delta = milliTimeD - lastRender
|
||||
lastRender = milliTimeD
|
||||
|
||||
RenderSystem.setShaderColor(0f, 0f, 0f, 0.6f)
|
||||
|
||||
@ -290,7 +291,7 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon
|
||||
|
||||
fun onRenderGuiEvent(event: RenderGuiEvent.Post) {
|
||||
if (!grabbedInput) {
|
||||
lastRender = System.nanoTime()
|
||||
lastRender = milliTimeD
|
||||
renderRegular(event)
|
||||
return
|
||||
} else {
|
||||
|
@ -22,6 +22,7 @@ import ru.dbotthepony.mc.otm.core.component1
|
||||
import ru.dbotthepony.mc.otm.core.component2
|
||||
import ru.dbotthepony.mc.otm.core.component3
|
||||
import ru.dbotthepony.mc.otm.core.linearInterpolation
|
||||
import ru.dbotthepony.mc.otm.milliTime
|
||||
import java.util.stream.Collectors
|
||||
import kotlin.math.absoluteValue
|
||||
import kotlin.math.ceil
|
||||
@ -479,10 +480,10 @@ object GlitchRenderer {
|
||||
RenderSystem.setShaderTexture(0, minecraft.mainRenderTarget.colorTextureId)
|
||||
|
||||
// color perception errors (eye-camera glitch)
|
||||
drawVHSLineGap((System.currentTimeMillis() % glitchBuffer.height).toDouble(), glitchBuffer.height * 0.025)
|
||||
drawVHSLineGap(((System.currentTimeMillis() + glitchBuffer.height / 2) % glitchBuffer.height).toDouble(), glitchBuffer.height * 0.075)
|
||||
drawVHSLineGap(((System.currentTimeMillis() + glitchBuffer.height / 3) % glitchBuffer.height).toDouble(), glitchBuffer.height * 0.04)
|
||||
drawVHSLineGap(((-System.currentTimeMillis() - glitchBuffer.height / 3) % glitchBuffer.height).toDouble().absoluteValue, glitchBuffer.height * 0.07)
|
||||
drawVHSLineGap((milliTime % glitchBuffer.height).toDouble(), glitchBuffer.height * 0.025)
|
||||
drawVHSLineGap(((milliTime + glitchBuffer.height / 2) % glitchBuffer.height).toDouble(), glitchBuffer.height * 0.075)
|
||||
drawVHSLineGap(((milliTime + glitchBuffer.height / 3) % glitchBuffer.height).toDouble(), glitchBuffer.height * 0.04)
|
||||
drawVHSLineGap(((-milliTime - glitchBuffer.height / 3) % glitchBuffer.height).toDouble().absoluteValue, glitchBuffer.height * 0.07)
|
||||
|
||||
// color encoding errors (encoder/transmission glitch)
|
||||
RenderSystem.setShaderColor(1f, 1f, 1f, 1f)
|
||||
|
@ -8,14 +8,13 @@ import com.mojang.math.Vector3f
|
||||
import net.minecraft.client.renderer.GameRenderer
|
||||
import net.minecraftforge.client.event.RenderLevelStageEvent
|
||||
import org.lwjgl.opengl.GL11.GL_LESS
|
||||
import ru.dbotthepony.mc.otm.client.minecraft
|
||||
import ru.dbotthepony.mc.otm.core.Vector
|
||||
import ru.dbotthepony.mc.otm.core.component1
|
||||
import ru.dbotthepony.mc.otm.core.component2
|
||||
import ru.dbotthepony.mc.otm.core.component3
|
||||
import ru.dbotthepony.mc.otm.core.linearInterpolation
|
||||
import ru.dbotthepony.mc.otm.core.position
|
||||
import ru.dbotthepony.mc.otm.network.ShockwaveEffectPacket
|
||||
import ru.dbotthepony.mc.otm.secondTimeD
|
||||
import kotlin.math.PI
|
||||
|
||||
object ShockwaveRenderer {
|
||||
@ -23,7 +22,7 @@ object ShockwaveRenderer {
|
||||
|
||||
private class State(val pos: Vector, val finalRadius: Float = 6f) {
|
||||
var radius = 0f
|
||||
var lastRender = System.nanoTime()
|
||||
var lastRender = secondTimeD
|
||||
|
||||
init {
|
||||
synchronized(activeShockwaves) {
|
||||
@ -32,10 +31,10 @@ object ShockwaveRenderer {
|
||||
}
|
||||
|
||||
fun render(event: RenderLevelStageEvent): Boolean {
|
||||
val diff = System.nanoTime() - lastRender
|
||||
val diff = secondTimeD - lastRender
|
||||
|
||||
radius += diff / (1_000_000_000f / EXPANSION_PER_SECOND)
|
||||
lastRender = System.nanoTime()
|
||||
radius += (diff * EXPANSION_PER_SECOND).toFloat()
|
||||
lastRender = secondTimeD
|
||||
|
||||
if (radius <= finalRadius) {
|
||||
val builder = tesselator.builder
|
||||
|
@ -4,6 +4,7 @@ import com.mojang.blaze3d.platform.InputConstants
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
import ru.dbotthepony.mc.otm.core.linearInterpolation
|
||||
import ru.dbotthepony.mc.otm.milliTimeD
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
open class AnalogScrollBarPanel<out S : Screen>(
|
||||
@ -93,7 +94,7 @@ open class AnalogScrollBarPanel<out S : Screen>(
|
||||
|
||||
val scrollButton = Button()
|
||||
|
||||
private var lastRender = System.nanoTime()
|
||||
private var lastRender = milliTimeD
|
||||
|
||||
override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
if (width == ScrollBarConstants.SLIM_WIDTH) {
|
||||
@ -106,12 +107,12 @@ open class AnalogScrollBarPanel<out S : Screen>(
|
||||
ScrollBarConstants.BOTTOM.render(stack, y = height - 2f)
|
||||
}
|
||||
|
||||
val time = System.nanoTime()
|
||||
val time = milliTimeD
|
||||
val diff = time - lastRender
|
||||
lastRender = time
|
||||
|
||||
if (scroll != smoothScroll) {
|
||||
smoothScroll = linearInterpolation(diff / 50_000_000.0, smoothScroll.toDouble(), scroll.toDouble()).toFloat()
|
||||
smoothScroll = linearInterpolation(diff / 50.0, smoothScroll.toDouble(), scroll.toDouble()).toFloat()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,12 +12,14 @@ import net.minecraft.network.chat.Component
|
||||
import net.minecraft.world.inventory.Slot
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import org.apache.logging.log4j.LogManager
|
||||
import ru.dbotthepony.mc.otm.SystemTime
|
||||
import ru.dbotthepony.mc.otm.client.minecraft
|
||||
import ru.dbotthepony.mc.otm.client.moveMousePosScaled
|
||||
import ru.dbotthepony.mc.otm.client.render.currentScissorRect
|
||||
import ru.dbotthepony.mc.otm.client.render.popScissorRect
|
||||
import ru.dbotthepony.mc.otm.client.render.pushScissorRect
|
||||
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
|
||||
import ru.dbotthepony.mc.otm.nanoTime
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
import kotlin.math.roundToInt
|
||||
@ -317,16 +319,16 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
return null
|
||||
}
|
||||
|
||||
var flashingSince: Long = Long.MIN_VALUE
|
||||
var flashingSince: SystemTime? = null
|
||||
private set
|
||||
|
||||
var isFlashing: Boolean
|
||||
get() = flashingSince != Long.MIN_VALUE && (System.nanoTime() - flashingSince) <= 1_000_000_000
|
||||
get() = (flashingSince?.seconds ?: Long.MAX_VALUE) <= 1
|
||||
set(value) {
|
||||
if (value) {
|
||||
flashingSince = System.nanoTime()
|
||||
flashingSince = SystemTime()
|
||||
} else {
|
||||
flashingSince = Long.MIN_VALUE
|
||||
flashingSince = null
|
||||
}
|
||||
}
|
||||
|
||||
@ -339,7 +341,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
val isFlashFrame: Boolean
|
||||
get() = isFlashing && (System.nanoTime() - flashingSince) % 400_000_000 <= 200_000_000
|
||||
get() = flashingSince != null && flashingSince!!.millis % 400L <= 200L
|
||||
|
||||
val isFlashFrameRecursive: Boolean
|
||||
get() {
|
||||
|
@ -1,7 +1,9 @@
|
||||
package ru.dbotthepony.mc.otm.client.screen.panels
|
||||
|
||||
import net.minecraft.world.inventory.Slot
|
||||
import ru.dbotthepony.mc.otm.SystemTime
|
||||
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
|
||||
import ru.dbotthepony.mc.otm.nanoTime
|
||||
|
||||
open class FoldableSlotPanel<out S : MatteryScreen<*>, out T : Slot> @JvmOverloads constructor(
|
||||
screen: S,
|
||||
@ -70,13 +72,13 @@ open class FoldableSlotPanel<out S : MatteryScreen<*>, out T : Slot> @JvmOverloa
|
||||
override val slot: T
|
||||
get() = mainSlot.slot
|
||||
|
||||
var hoveringSince: Long? = null
|
||||
var hoveringSince: SystemTime? = null
|
||||
protected set
|
||||
var hoverPanel: HoverPanel? = null
|
||||
protected set
|
||||
|
||||
override fun onHovered() {
|
||||
hoveringSince = System.nanoTime()
|
||||
hoveringSince = SystemTime()
|
||||
}
|
||||
|
||||
override fun onUnHovered() {
|
||||
@ -92,7 +94,7 @@ open class FoldableSlotPanel<out S : MatteryScreen<*>, out T : Slot> @JvmOverloa
|
||||
|
||||
val hoveringSince = hoveringSince
|
||||
|
||||
if (hoveringSince != null && System.nanoTime() - hoveringSince >= MAX_HOVER_TIME && hoverPanel == null && extraSlots.isNotEmpty()) {
|
||||
if (hoveringSince != null && hoveringSince.nanos >= MAX_HOVER_TIME && hoverPanel == null && extraSlots.isNotEmpty()) {
|
||||
hoverPanel = HoverPanel()
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
|
||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||
import ru.dbotthepony.mc.otm.core.formatMatterLevel
|
||||
import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget
|
||||
import ru.dbotthepony.mc.otm.nanoTime
|
||||
import kotlin.math.absoluteValue
|
||||
import kotlin.math.cos
|
||||
import kotlin.math.pow
|
||||
@ -36,7 +37,7 @@ open class MatterGaugePanel<S : Screen> @JvmOverloads constructor(
|
||||
private var wavesStrength = 0.5f
|
||||
private var lastAbsoluteX = 0f
|
||||
private var lastAbsoluteY = 0f
|
||||
private var lastDraw = System.nanoTime()
|
||||
private var lastDraw = nanoTime
|
||||
private var lastLevel = 0f
|
||||
|
||||
protected open fun makeTooltip(): MutableList<Component> {
|
||||
@ -53,7 +54,7 @@ open class MatterGaugePanel<S : Screen> @JvmOverloads constructor(
|
||||
if (lastAbsoluteX == 0f && lastAbsoluteY == 0f) {
|
||||
lastAbsoluteX = absoluteX
|
||||
lastAbsoluteY = absoluteY
|
||||
lastDraw = System.nanoTime()
|
||||
lastDraw = nanoTime
|
||||
lastLevel = widget.percentage()
|
||||
} else {
|
||||
val diff = ((lastAbsoluteX - absoluteX).pow(2f) + (lastAbsoluteY - absoluteY).pow(2f)).pow(0.5f) / 10f + (lastLevel - widget.percentage()).absoluteValue * 1.5f
|
||||
@ -61,8 +62,8 @@ open class MatterGaugePanel<S : Screen> @JvmOverloads constructor(
|
||||
lastAbsoluteX = absoluteX
|
||||
lastAbsoluteY = absoluteY
|
||||
|
||||
wavesStrength = (wavesStrength + diff - (System.nanoTime() - lastDraw) / 400_000_000f).coerceAtLeast(0.5f).coerceAtMost(16f)
|
||||
lastDraw = System.nanoTime()
|
||||
wavesStrength = (wavesStrength + diff - (nanoTime - lastDraw) / 400_000_000f).coerceAtLeast(0.5f).coerceAtMost(16f)
|
||||
lastDraw = nanoTime
|
||||
lastLevel = widget.percentage()
|
||||
}
|
||||
|
||||
|
@ -295,7 +295,7 @@ abstract class AbstractWeaponItem<D : WeaponDataTable>(val tables: KClass<D>, ra
|
||||
|
||||
val time = System.nanoTime()
|
||||
val diff = abs(lastFovTime - time)
|
||||
lastFov = linearInterpolation(diff.coerceAtLeast(0).coerceAtMost(10_000_000L).toDouble() / 10_000_000.0, lastFov, interp).coerceAtLeast(0.001)
|
||||
lastFov = linearInterpolation(diff.coerceIn(0L, 10_000_000L).toDouble() / 10_000_000.0, lastFov, interp).coerceAtLeast(0.001)
|
||||
lastFovTime = time
|
||||
|
||||
event.fov /= lastFov
|
||||
|
@ -6,6 +6,8 @@ import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap
|
||||
import it.unimi.dsi.fastutil.objects.ReferenceArraySet
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import ru.dbotthepony.mc.otm.core.*
|
||||
import ru.dbotthepony.mc.otm.nanoTime
|
||||
import ru.dbotthepony.mc.otm.secondTime
|
||||
import java.io.DataInputStream
|
||||
import java.io.DataOutputStream
|
||||
import java.io.InputStream
|
||||
@ -314,7 +316,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa
|
||||
private val endpoints = ArrayList<WeakReference<Endpoint>>(1)
|
||||
val defaultEndpoint = Endpoint()
|
||||
|
||||
private var lastEndpointsCleanup = System.nanoTime()
|
||||
private var nextEndpointsCleanup = secondTime
|
||||
|
||||
private fun notifyEndpoints(dirtyField: IField<*>) {
|
||||
hasChanges = true
|
||||
@ -325,7 +327,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa
|
||||
}
|
||||
|
||||
private inline fun forEachEndpoint(execute: (Endpoint) -> Unit) {
|
||||
lastEndpointsCleanup = System.nanoTime()
|
||||
nextEndpointsCleanup = secondTime + 60
|
||||
|
||||
synchronized(endpoints) {
|
||||
val iterator = endpoints.listIterator()
|
||||
@ -353,8 +355,8 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa
|
||||
endpoints.add(WeakReference(this))
|
||||
endpointsMaxCapacity = endpointsMaxCapacity.coerceAtLeast(endpoints.size)
|
||||
|
||||
if (System.nanoTime() - lastEndpointsCleanup >= 60_000_000_000) {
|
||||
lastEndpointsCleanup = System.nanoTime()
|
||||
if (secondTime >= nextEndpointsCleanup) {
|
||||
nextEndpointsCleanup = secondTime + 60
|
||||
|
||||
val iterator = endpoints.listIterator()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user