Kotlin Multiplatform implementation of threads, timers, atomic references, string utilities and iso8601 dates.
AtomicReference implementation on all platform
val atom = AtomicReference("a")
atom.compareAndSet("a", "b")
atom.setOrThrow("c", "b") // Will throw
val list = AtomicListReference<String>()
list.add("a") // Thread safely adds "a"
list.remove("a") // Thread safely removes "a"
Single and repeatable multiplatform timer implementations
val doOnceTimer = TimerFactory.single(12.seconds) { doSomething() }
val repeatTimer = TimerFactory.repeatable(12.seconds) { doSomething() }
repeatTimer.cancel() // stop the timer
Multiplatform string extensions for formating, normalizing
val string = "Où sont les bûches de Noël durant l'été?".normalize()
string == "Ou sont les buches de Noel durant l'ete?" // true
Multiplatform iso date implementation is provided by kotlinx-datetime
While waiting for Sharing of coroutines across threads in Kotlin/Native to work correctly. Trikot.foundation provide a standard Thread model based on queues. When this issue will be resolved, DispatchQueues will be converted to Coroutines.
See: Dispatch Queues
build.gradle
dependencies {
maven { url("https://s3.amazonaws.com/mirego-maven/public") }
}
ios() {
binaries {
framework {
export "com.mirego.trikot:trikotFoundation:$trikot_version"
}
}
}
sourceSets {
commonMain {
dependencies {
implementation "com.mirego.trikot:trikotFoundation:$trikot_version"
}
}
}