All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.dev.mokkery.internal.Counter.kt Maven / Gradle / Ivy

Go to download

Mokkery is a mocking library for Kotlin Multiplatform, easy to use, boilerplate-free and compiler plugin driven.

The newest version!
package dev.mokkery.internal

import kotlinx.atomicfu.atomic

internal fun interface Counter {

    fun next(): Long

    companion object {

        private val _callsClock = MonotonicCounter(Long.MIN_VALUE)
        private val _mocksCounter = MonotonicCounter(1)
        val calls: Counter = _callsClock
        val mocks: Counter = _mocksCounter
    }
}

internal class MonotonicCounter(start: Long): Counter {

    private val current = atomic(start)

    override fun next(): Long = current.getAndIncrement()

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy