Skip to content

Commit a90920d

Browse files
1Jajen1nomisRev
andauthored
STM implementation (#270)
* Initial implementation * Remove transaction from waiting list when it resumes * Add a few useful stm datastructures TMap and TSet need some work * Use 64bit numbers for ids and just ignore rollover * Smarter lock acquisition and start docs * Fixes * 🔥 unused imports * Align api's of datatypes with our non-stm types Also removed TMap and TSet for now * Start testing datatypes Also fixed some bugs * More tests and small bug fixes * Linter and test registerDelay * Move exception handling to catch try catch does not work because it keeps side-effects made in try * 🔥 unused import * Fix tests after exception handling refractor * Much smarter lock strategy * Fix some issues with blocking retry introduced by lock rework * Use a mutable list for waiting transactions Should save some time spent copying the list... * Lock and release tvars right away when retrying Before it locked everything first and unlocked them again later, blocking all variables till all of them had transactions registered * Add two example cases to the tests * Documentation and a few TODO's with optimization ideas * More documentation * Fix TSem.checkNonNegative * Fix ank example * Add an article about managing shared state in concurrent settings The article presents the problem (race-conditions) and various solutions and their downsides/tradeoffs. * Change locking strategy to retry if we encounter a lock In 99% of the cases trying to validate a locked TVar means it is being updated and thus invalid. * Use a different List implementation for queues This does not pressure the gc as much because it is sharing. It is also very fast for head access * Add TMap/TSet and move some stuff around Also removed the need for blocking locking and changed how nested transactions run * Linter * Handle colliding hash values better * Fix TMVar for nullable values. TMVar(null) is not empty! * Update arrow-docs/docs/fx/managing-state/README.md Co-authored-by: Simon Vergauwen <[email protected]> * Update arrow-docs/docs/fx/managing-state/README.md Co-authored-by: Simon Vergauwen <[email protected]> * Update arrow-docs/docs/fx/managing-state/README.md Co-authored-by: Simon Vergauwen <[email protected]> * Remove managing state for now. Gonna redo that at some point * Remove suspend encoding It was unnecessary to begin with and this allows easier interleaving with effects * 🔥 Unused imports * Move STM to its own module * Fix doc build * Override fillInStackTrace for RetryException * Address a few now inaccurate doc bits * Some more outdated docs + slight doc changes * Update STM.kt Co-authored-by: Simon Vergauwen <[email protected]>
1 parent dc8f9ad commit a90920d

22 files changed

+2395
-0
lines changed

arrow-libs/fx/arrow-docs/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ dependencies {
2828
compile "io.arrow-kt:arrow-meta:$VERSION_NAME"
2929
compile project(":arrow-fx")
3030
compile project(":arrow-fx-coroutines")
31+
compile project(":arrow-fx-stm")
3132
compile project(":arrow-fx-rx2")
3233
compile project(":arrow-fx-reactor")
3334
compile project(":arrow-fx-kotlinx-coroutines")
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
plugins {
2+
id "org.jetbrains.kotlin.jvm"
3+
id "org.jlleitschuh.gradle.ktlint"
4+
}
5+
6+
apply plugin: 'kotlinx-atomicfu'
7+
8+
apply from: "$SUB_PROJECT"
9+
apply from: "$DOC_CREATION"
10+
11+
dependencies {
12+
compile project(":arrow-fx-coroutines")
13+
14+
testImplementation "io.kotest:kotest-runner-junit5-jvm:$KOTEST_VERSION" // for kotest framework
15+
testImplementation "io.kotest:kotest-assertions-core-jvm:$KOTEST_VERSION" // for kotest core jvm assertions
16+
testImplementation "io.kotest:kotest-property-jvm:$KOTEST_VERSION" // for kotest property test
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Maven publishing configuration
2+
POM_NAME=Arrow-Fx-STM
3+
POM_ARTIFACT_ID=arrow-fx-stm
4+
POM_PACKAGING=jar

0 commit comments

Comments
 (0)