mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-10-18 05:40:25 +00:00
Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
837758aebe | |||
6ac4149aa1 | |||
278584ae6a | |||
126f9d5f41 | |||
ce15ff4e0a | |||
382b956beb | |||
36deab4909 | |||
550fc59d9d | |||
9100a57458 | |||
74d9bbccd9 | |||
75e602a349 | |||
e73644db10 | |||
148e6bdae7 |
21
.github/workflows/dokka_push.yml
vendored
Normal file
21
.github/workflows/dokka_push.yml
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
name: Publish KDocs
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
jobs:
|
||||||
|
publishing:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-java@v1
|
||||||
|
with:
|
||||||
|
java-version: 1.8
|
||||||
|
- name: Build
|
||||||
|
run: ./gradlew dokkaHtml
|
||||||
|
- name: Publish KDocs
|
||||||
|
uses: peaceiris/actions-gh-pages@v3
|
||||||
|
with:
|
||||||
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
publish_dir: ./dokka/build/dokka/html
|
||||||
|
publish_branch: kdocs
|
22
CHANGELOG.md
22
CHANGELOG.md
@@ -1,5 +1,27 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 0.4.34
|
||||||
|
|
||||||
|
* `Versions`:
|
||||||
|
* `uuid`: `0.2.3` -> `0.2.4`
|
||||||
|
* `Repos`:
|
||||||
|
* `AbstractExposedCRUDRepo` now implements `StandardCRUDRepo`
|
||||||
|
* `AbstractMutableAndroidCRUDRepo` now implements `StandardCRUDRepo`
|
||||||
|
|
||||||
|
## 0.4.33
|
||||||
|
|
||||||
|
* `Versions`:
|
||||||
|
* `Ktor`: `1.5.2` -> `1.5.3`
|
||||||
|
* `Coroutines`
|
||||||
|
* Add `WeakJob` workaround:
|
||||||
|
* `CoroutineScope#weakLaunch`
|
||||||
|
* `CoroutineScope#weakAsync`
|
||||||
|
|
||||||
|
## 0.4.32
|
||||||
|
|
||||||
|
* `Versions`:
|
||||||
|
* `Kotlin Exposed`: `0.29.1` -> `0.30.1`
|
||||||
|
|
||||||
## 0.4.31
|
## 0.4.31
|
||||||
|
|
||||||
* `Versions`:
|
* `Versions`:
|
||||||
|
@@ -0,0 +1,31 @@
|
|||||||
|
package dev.inmo.micro_utils.coroutines
|
||||||
|
|
||||||
|
import kotlinx.coroutines.*
|
||||||
|
import kotlin.coroutines.CoroutineContext
|
||||||
|
import kotlin.coroutines.EmptyCoroutineContext
|
||||||
|
|
||||||
|
private fun CoroutineScope.createWeakSubScope() = CoroutineScope(coroutineContext.minusKey(Job)).also { newScope ->
|
||||||
|
coroutineContext.job.invokeOnCompletion { newScope.cancel() }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun CoroutineScope.weakLaunch(
|
||||||
|
context: CoroutineContext = EmptyCoroutineContext,
|
||||||
|
start: CoroutineStart = CoroutineStart.DEFAULT,
|
||||||
|
block: suspend CoroutineScope.() -> Unit
|
||||||
|
): Job {
|
||||||
|
val scope = createWeakSubScope()
|
||||||
|
val job = scope.launch(context, start, block)
|
||||||
|
job.invokeOnCompletion { scope.cancel() }
|
||||||
|
return job
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T> CoroutineScope.weakAsync(
|
||||||
|
context: CoroutineContext = EmptyCoroutineContext,
|
||||||
|
start: CoroutineStart = CoroutineStart.DEFAULT,
|
||||||
|
block: suspend CoroutineScope.() -> T
|
||||||
|
): Deferred<T> {
|
||||||
|
val scope = createWeakSubScope()
|
||||||
|
val deferred = scope.async(context, start, block)
|
||||||
|
deferred.invokeOnCompletion { scope.cancel() }
|
||||||
|
return deferred
|
||||||
|
}
|
@@ -0,0 +1,40 @@
|
|||||||
|
package dev.inmo.micro_utils.coroutines
|
||||||
|
|
||||||
|
import kotlinx.coroutines.*
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class WeakJob {
|
||||||
|
@Test
|
||||||
|
fun `test that weak jobs works correctly`() {
|
||||||
|
val scope = CoroutineScope(Dispatchers.Default)
|
||||||
|
lateinit var weakLaunchJob: Job
|
||||||
|
lateinit var weakAsyncJob: Job
|
||||||
|
scope.launchSynchronously {
|
||||||
|
val completeDeferred = Job()
|
||||||
|
coroutineScope {
|
||||||
|
weakLaunchJob = weakLaunch {
|
||||||
|
while (isActive) {
|
||||||
|
delay(100L)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
weakAsyncJob = weakAsync {
|
||||||
|
while (isActive) {
|
||||||
|
delay(100L)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
coroutineContext.job.invokeOnCompletion {
|
||||||
|
scope.launch {
|
||||||
|
delay(1000L)
|
||||||
|
completeDeferred.complete()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
launch { delay(1000L); cancel() }
|
||||||
|
}
|
||||||
|
completeDeferred.join()
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(!weakLaunchJob.isActive)
|
||||||
|
assert(!weakAsyncJob.isActive)
|
||||||
|
}
|
||||||
|
}
|
@@ -9,15 +9,15 @@ android.enableJetifier=true
|
|||||||
kotlin_version=1.4.32
|
kotlin_version=1.4.32
|
||||||
kotlin_coroutines_version=1.4.3
|
kotlin_coroutines_version=1.4.3
|
||||||
kotlin_serialisation_core_version=1.1.0
|
kotlin_serialisation_core_version=1.1.0
|
||||||
kotlin_exposed_version=0.29.1
|
kotlin_exposed_version=0.30.1
|
||||||
|
|
||||||
ktor_version=1.5.2
|
ktor_version=1.5.3
|
||||||
|
|
||||||
klockVersion=2.0.7
|
klockVersion=2.0.7
|
||||||
|
|
||||||
github_release_plugin_version=2.2.12
|
github_release_plugin_version=2.2.12
|
||||||
|
|
||||||
uuidVersion=0.2.3
|
uuidVersion=0.2.4
|
||||||
|
|
||||||
# ANDROID
|
# ANDROID
|
||||||
|
|
||||||
@@ -39,10 +39,10 @@ crypto_js_version=4.0.0
|
|||||||
|
|
||||||
# Dokka
|
# Dokka
|
||||||
|
|
||||||
dokka_version=1.4.20
|
dokka_version=1.4.30
|
||||||
|
|
||||||
# Project data
|
# Project data
|
||||||
|
|
||||||
group=dev.inmo
|
group=dev.inmo
|
||||||
version=0.4.31
|
version=0.4.34
|
||||||
android_code_version=35
|
android_code_version=38
|
||||||
|
@@ -8,7 +8,8 @@ import kotlinx.coroutines.flow.*
|
|||||||
abstract class AbstractMutableAndroidCRUDRepo<ObjectType, IdType, InputValueType>(
|
abstract class AbstractMutableAndroidCRUDRepo<ObjectType, IdType, InputValueType>(
|
||||||
helper: StandardSQLHelper
|
helper: StandardSQLHelper
|
||||||
) : WriteStandardCRUDRepo<ObjectType, IdType, InputValueType>,
|
) : WriteStandardCRUDRepo<ObjectType, IdType, InputValueType>,
|
||||||
AbstractAndroidCRUDRepo<ObjectType, IdType>(helper) {
|
AbstractAndroidCRUDRepo<ObjectType, IdType>(helper),
|
||||||
|
StandardCRUDRepo<ObjectType, IdType, InputValueType> {
|
||||||
protected val newObjectsChannel = MutableSharedFlow<ObjectType>(64)
|
protected val newObjectsChannel = MutableSharedFlow<ObjectType>(64)
|
||||||
protected val updateObjectsChannel = MutableSharedFlow<ObjectType>(64)
|
protected val updateObjectsChannel = MutableSharedFlow<ObjectType>(64)
|
||||||
protected val deleteObjectsIdsChannel = MutableSharedFlow<IdType>(64)
|
protected val deleteObjectsIdsChannel = MutableSharedFlow<IdType>(64)
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
package dev.inmo.micro_utils.repos.exposed
|
package dev.inmo.micro_utils.repos.exposed
|
||||||
|
|
||||||
|
import dev.inmo.micro_utils.repos.StandardCRUDRepo
|
||||||
|
|
||||||
abstract class AbstractExposedCRUDRepo<ObjectType, IdType, InputValueType>(
|
abstract class AbstractExposedCRUDRepo<ObjectType, IdType, InputValueType>(
|
||||||
flowsChannelsSize: Int = 0,
|
flowsChannelsSize: Int = 0,
|
||||||
tableName: String = ""
|
tableName: String = ""
|
||||||
@@ -8,4 +10,5 @@ abstract class AbstractExposedCRUDRepo<ObjectType, IdType, InputValueType>(
|
|||||||
flowsChannelsSize,
|
flowsChannelsSize,
|
||||||
tableName
|
tableName
|
||||||
),
|
),
|
||||||
ExposedCRUDRepo<ObjectType, IdType>
|
ExposedCRUDRepo<ObjectType, IdType>,
|
||||||
|
StandardCRUDRepo<ObjectType, IdType, InputValueType>
|
||||||
|
Reference in New Issue
Block a user