mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-10-25 01:00:36 +00:00
potentially first version of SmartKeyRWLocker
This commit is contained in:
@@ -19,7 +19,7 @@ class RollbackContext<T> internal constructor (
|
||||
*
|
||||
* @param rollback Will be called if
|
||||
*/
|
||||
suspend fun <T> TransactionsDSL.rollbackableOperation(
|
||||
suspend fun <T> TransactionsDSL.rollableBackOperation(
|
||||
rollback: suspend RollbackContext<T>.() -> Unit,
|
||||
action: suspend () -> T
|
||||
): T {
|
||||
@@ -34,7 +34,7 @@ suspend fun <T> TransactionsDSL.rollbackableOperation(
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts transaction with opportunity to add actions [rollbackableOperation]. How to use:
|
||||
* Starts transaction with opportunity to add actions [rollableBackOperation]. How to use:
|
||||
*
|
||||
* ```kotlin
|
||||
* doSuspendTransaction {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import dev.inmo.micro_utils.transactions.doSuspendTransaction
|
||||
import dev.inmo.micro_utils.transactions.rollbackableOperation
|
||||
import dev.inmo.micro_utils.transactions.rollableBackOperation
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
@@ -19,7 +19,7 @@ class TransactionsDSLTests {
|
||||
|
||||
val actionResult = doSuspendTransaction {
|
||||
dataCollections.forEachIndexed { i, _ ->
|
||||
val resultData = rollbackableOperation({
|
||||
val resultData = rollableBackOperation({
|
||||
dataCollections[i] = actionResult.copy(second = true)
|
||||
}) {
|
||||
val result = dataCollections[i]
|
||||
@@ -56,7 +56,7 @@ class TransactionsDSLTests {
|
||||
|
||||
val actionResult = doSuspendTransaction {
|
||||
dataCollections.forEachIndexed { i, _ ->
|
||||
val resultData = rollbackableOperation({
|
||||
val resultData = rollableBackOperation({
|
||||
assertTrue(error === this.error)
|
||||
dataCollections[i] = actionResult.copy(second = true)
|
||||
}) {
|
||||
|
||||
Reference in New Issue
Block a user