From 3c33eb3bd9af6260fd1e8dfe35ae3e102b2e1c91 Mon Sep 17 00:00:00 2001 From: sergeych Date: Mon, 19 Feb 2024 03:33:45 +0300 Subject: [PATCH] refactored packages, added more docs --- docs/bipack.md | 17 +++++++++++++++-- .../net.sergeych.bintools/DataKVStorage.kt | 4 ++-- .../net/sergeych/synctools/AtomicCounter.kt | 2 +- .../net/sergeych/synctools/AtomicValue.kt | 2 +- .../net/sergeych/synctools/ProtectedOp.kt | 2 +- .../net/sergeych/synctools/ProtectedOp.js.kt | 2 +- .../net/sergeych/synctools/ProtectedOp.jvm.kt | 2 +- .../sergeych/synctools/ProtectedOp.native.kt | 2 +- 8 files changed, 23 insertions(+), 10 deletions(-) diff --git a/docs/bipack.md b/docs/bipack.md index 1f2e769..e0c2a43 100644 --- a/docs/bipack.md +++ b/docs/bipack.md @@ -1,6 +1,13 @@ # Module mp_bintools -This library contains a `Bipack` binary format serializer, see [net.sergeych.bipack.BipackEncoder] and [net.sergeych.bipack.BipackDecoder]. Also, there are many general-purpose utilities that simplify binary data processing, see package [net.sergeych.bintools] below. +## Collection of binary tools + +Most interesting: + +- Full set of CRC: [net.sergeych.bintools.CRC] +- Binary bit-effective __BiPack format__ serializer: [net.sergeych.bipack.BipackEncoder] and [net.sergeych.bipack.BipackDecoder]. Also typed key-value storage for it, see [net.sergeych.bipack.KVStorage] and its delegates and [net.sergeych.bipack.defaultNamedStorage]. +- Multiplatform synchronization tools, that works the same and properly on JS, native and JVM, see [net.sergeych.synctools] +- many general-purpose utilities that simplify binary data processing, see package [net.sergeych.bintools] below. # Package net.sergeych.bipack @@ -16,4 +23,10 @@ There are also special annotation to fine tune the format: [Extendable], [Framed General-purpose binary tools: encoding to bytes, hex, binary dumps. variable length integer, ect. Most of it is used internally by bipack serializers, see [net.sergeych.bipack] for details. -In particular, see [Varint] and [Smartint] variable-length compact integer codecs and also [DataSource] and [DataSink] multiplatform synchronous read/write interfaces. \ No newline at end of file +In particular, see [Varint] and [Smartint] variable-length compact integer codecs and also [DataSource] and [DataSink] multiplatform synchronous read/write interfaces. + +# Package net.sergeych.synctools + +To write a code that compiles and runs, and most likely works on the +JS, native, and JVM, we need some portable/compatible synchronization +primitives. This package is a collection of such. \ No newline at end of file diff --git a/src/commonMain/kotlin/net.sergeych.bintools/DataKVStorage.kt b/src/commonMain/kotlin/net.sergeych.bintools/DataKVStorage.kt index 39d9d6b..e0fa2a6 100644 --- a/src/commonMain/kotlin/net.sergeych.bintools/DataKVStorage.kt +++ b/src/commonMain/kotlin/net.sergeych.bintools/DataKVStorage.kt @@ -2,9 +2,9 @@ package net.sergeych.bintools import net.sergeych.bipack.BipackDecoder import net.sergeych.bipack.BipackEncoder +import net.sergeych.synctools.ProtectedOp import net.sergeych.synctools.WaitHandle -import net.sergeych.tools.ProtectedOp -import net.sergeych.tools.withLock +import net.sergeych.synctools.withLock class DataKVStorage(private val provider: DataProvider) : KVStorage { diff --git a/src/commonMain/kotlin/net/sergeych/synctools/AtomicCounter.kt b/src/commonMain/kotlin/net/sergeych/synctools/AtomicCounter.kt index 80c625f..abbc8e2 100644 --- a/src/commonMain/kotlin/net/sergeych/synctools/AtomicCounter.kt +++ b/src/commonMain/kotlin/net/sergeych/synctools/AtomicCounter.kt @@ -1,4 +1,4 @@ -package net.sergeych.tools +package net.sergeych.synctools /** * Thread-safe multiplatform counter diff --git a/src/commonMain/kotlin/net/sergeych/synctools/AtomicValue.kt b/src/commonMain/kotlin/net/sergeych/synctools/AtomicValue.kt index 3fa79ea..49cf98e 100644 --- a/src/commonMain/kotlin/net/sergeych/synctools/AtomicValue.kt +++ b/src/commonMain/kotlin/net/sergeych/synctools/AtomicValue.kt @@ -1,4 +1,4 @@ -package net.sergeych.tools +package net.sergeych.synctools /** * Multiplatform (JS and battery included) atomically mutable value. diff --git a/src/commonMain/kotlin/net/sergeych/synctools/ProtectedOp.kt b/src/commonMain/kotlin/net/sergeych/synctools/ProtectedOp.kt index aca0823..f76f841 100644 --- a/src/commonMain/kotlin/net/sergeych/synctools/ProtectedOp.kt +++ b/src/commonMain/kotlin/net/sergeych/synctools/ProtectedOp.kt @@ -1,4 +1,4 @@ -package net.sergeych.tools +package net.sergeych.synctools import kotlin.contracts.ExperimentalContracts import kotlin.contracts.InvocationKind diff --git a/src/jsMain/kotlin/net/sergeych/synctools/ProtectedOp.js.kt b/src/jsMain/kotlin/net/sergeych/synctools/ProtectedOp.js.kt index 82ec7b8..8c0e703 100644 --- a/src/jsMain/kotlin/net/sergeych/synctools/ProtectedOp.js.kt +++ b/src/jsMain/kotlin/net/sergeych/synctools/ProtectedOp.js.kt @@ -1,4 +1,4 @@ -package net.sergeych.tools +package net.sergeych.synctools /** * JS is single-threaded, so we don't need any additional protection: diff --git a/src/jvmMain/kotlin/net/sergeych/synctools/ProtectedOp.jvm.kt b/src/jvmMain/kotlin/net/sergeych/synctools/ProtectedOp.jvm.kt index ccc8e1d..18cdd15 100644 --- a/src/jvmMain/kotlin/net/sergeych/synctools/ProtectedOp.jvm.kt +++ b/src/jvmMain/kotlin/net/sergeych/synctools/ProtectedOp.jvm.kt @@ -1,4 +1,4 @@ -package net.sergeych.tools +package net.sergeych.synctools import java.util.concurrent.locks.ReentrantLock diff --git a/src/nativeMain/kotlin/net/sergeych/synctools/ProtectedOp.native.kt b/src/nativeMain/kotlin/net/sergeych/synctools/ProtectedOp.native.kt index 78f6279..6ce1e55 100644 --- a/src/nativeMain/kotlin/net/sergeych/synctools/ProtectedOp.native.kt +++ b/src/nativeMain/kotlin/net/sergeych/synctools/ProtectedOp.native.kt @@ -1,4 +1,4 @@ -package net.sergeych.tools +package net.sergeych.synctools import kotlinx.atomicfu.locks.ReentrantLock