-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert to using stately-collections to ensure JVM thread-safety. (#27)
- Loading branch information
1 parent
3696359
commit ef04232
Showing
7 changed files
with
60 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 0 additions & 13 deletions
13
cache4k/src/commonMain/kotlin/io/github/reactivecircus/cache4k/MutableSetExt.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
cache4k/src/commonMain/kotlin/io/github/reactivecircus/cache4k/ReorderingIsoMutableSet.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package io.github.reactivecircus.cache4k | ||
|
||
import co.touchlab.stately.collections.IsoMutableSet | ||
|
||
/** | ||
* A custom [IsoMutableSet] that updates the insertion order when an element is re-inserted, | ||
* i.e. an inserted element will always be placed at the end | ||
* regardless of whether the element already exists. | ||
*/ | ||
internal class ReorderingIsoMutableSet<T> : IsoMutableSet<T>(), MutableSet<T> { | ||
override fun add(element: T): Boolean = access { | ||
val exists = remove(element) | ||
super.add(element) | ||
// respect the contract "true if this set did not already contain the specified element" | ||
!exists | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters