Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ org.gradle.jvmargs=-XX:MaxMetaspaceSize=2G

# POM file
GROUP=org.mobilenativefoundation.store
VERSION_NAME=5.1.0-alpha06
VERSION_NAME=5.1.0-alpha07
POM_PACKAGING=pom
POM_DESCRIPTION = Store5 is a Kotlin Multiplatform network-resilient repository layer

Expand Down
3 changes: 1 addition & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ testCore = "1.6.1"
kmmBridge = "0.3.2"
ktlint = "0.39.0"
kover = "0.9.0-RC"
store = "5.1.0-alpha06"
store = "5.1.0-alpha07"
truth = "1.1.3"
turbine = "1.2.0"
binary-compatibility-validator = "0.15.0-Beta.2"
Expand All @@ -48,7 +48,6 @@ kotlinx-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-
kotlinx-coroutines-android = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-android", version.ref = "kotlinxCoroutines" }
kotlinx-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "kotlinxCoroutines" }
kotlinx-coroutines-rx2 = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-rx2", version.ref = "kotlinxCoroutines" }
kotlinx-datetime = { group = "org.jetbrains.kotlinx", name = "kotlinx-datetime", version = "0.6.2" }
molecule-gradle-plugin = { module = "app.cash.molecule:molecule-gradle-plugin", version.ref = "moleculeGradlePlugin" }
molecule-runtime = { module = "app.cash.molecule:molecule-runtime", version.ref = "moleculeGradlePlugin" }
rxjava = { group = "io.reactivex.rxjava2", name = "rxjava", version = "2.2.21" }
Expand Down
1 change: 0 additions & 1 deletion store/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ kotlin {
implementation(libs.kotlin.stdlib)
implementation(libs.kotlinx.coroutines.core)
implementation(libs.kotlinx.serialization.core)
implementation(libs.kotlinx.datetime)
api(libs.kotlinx.atomic.fu)
implementation(libs.touchlab.kermit)
implementation(projects.multicast)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package org.mobilenativefoundation.store.store5.impl.extensions

internal actual fun currentTimeMillis(): Long = System.currentTimeMillis()
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.mobilenativefoundation.store.store5

import kotlinx.datetime.Clock
import org.mobilenativefoundation.store.store5.impl.OnStoreWriteCompletion
import org.mobilenativefoundation.store.store5.impl.RealStoreWriteRequest
import org.mobilenativefoundation.store.store5.impl.extensions.currentTimeMillis

interface StoreWriteRequest<Key : Any, Output : Any, Response : Any> {
val key: Key
Expand All @@ -15,7 +15,7 @@ interface StoreWriteRequest<Key : Any, Output : Any, Response : Any> {
key: Key,
value: Output,
onCompletions: List<OnStoreWriteCompletion>? = null,
created: Long = Clock.System.now().toEpochMilliseconds(),
created: Long = currentTimeMillis(),
): StoreWriteRequest<Key, Output, Response> = RealStoreWriteRequest(key, value, created, onCompletions)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.mobilenativefoundation.store.store5.impl.extensions

import kotlin.time.Duration.Companion.hours

internal expect fun currentTimeMillis(): Long

internal fun now() = currentTimeMillis()

internal fun inHours(n: Int) = currentTimeMillis() + n.hours.inWholeMilliseconds

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.mobilenativefoundation.store.store5.impl.extensions

import kotlinx.cinterop.ExperimentalForeignApi
import kotlinx.cinterop.alloc
import kotlinx.cinterop.memScoped
import kotlinx.cinterop.ptr
import platform.posix.gettimeofday
import platform.posix.timeval

@OptIn(ExperimentalForeignApi::class)
internal actual fun currentTimeMillis(): Long =
memScoped {
val tv = alloc<timeval>()
gettimeofday(tv.ptr, null)
(tv.tv_sec.toLong() * 1000L) + (tv.tv_usec.toLong() / 1000L)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.mobilenativefoundation.store.store5.impl.extensions

@Suppress("UnsafeCastFromDynamic")
internal actual fun currentTimeMillis(): Long =
kotlin.js.Date
.now()
.toLong()
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package org.mobilenativefoundation.store.store5.impl.extensions

internal actual fun currentTimeMillis(): Long = System.currentTimeMillis()
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.mobilenativefoundation.store.store5.impl.extensions

import kotlinx.cinterop.ExperimentalForeignApi
import kotlinx.cinterop.alloc
import kotlinx.cinterop.memScoped
import kotlinx.cinterop.ptr
import platform.posix.gettimeofday
import platform.posix.timeval

@OptIn(ExperimentalForeignApi::class)
internal actual fun currentTimeMillis(): Long =
memScoped {
val tv = alloc<timeval>()
gettimeofday(tv.ptr, null)
(tv.tv_sec.toLong() * 1000L) + (tv.tv_usec.toLong() / 1000L)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.mobilenativefoundation.store.store5.impl.extensions

@JsFun("() => Date.now()")
private external fun dateNow(): Double

internal actual fun currentTimeMillis(): Long = dateNow().toLong()
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ object Versions {
const val COMPILE_SDK = 34
const val MIN_SDK = 24
const val TARGET_SDK = 34
const val STORE = "5.1.0-alpha06"
const val STORE = "5.1.0-alpha07"
}


Expand Down
Loading