Sandbox and minor fixes
This commit is contained in:
parent
76943a0af0
commit
d21842bee6
@ -46,7 +46,6 @@ xomrk {
|
|||||||
dependencies {
|
dependencies {
|
||||||
compileOnly("org.jetbrains:annotations:26.0.2")
|
compileOnly("org.jetbrains:annotations:26.0.2")
|
||||||
compileOnly("com.intellij:annotations:9.0.4")
|
compileOnly("com.intellij:annotations:9.0.4")
|
||||||
compileOnly("com.intellij:annotations:9.0.4")
|
|
||||||
implementation("it.unimi.dsi:fastutil:6.3")
|
implementation("it.unimi.dsi:fastutil:6.3")
|
||||||
implementation("ru.landgrafhomyak.utility:highlevel-try-finally:0.4")
|
implementation("ru.landgrafhomyak.utility:highlevel-try-finally:0.4")
|
||||||
implementation("ru.landgrafhomyak.utility:reference-counter:0.1")
|
implementation("ru.landgrafhomyak.utility:reference-counter:0.1")
|
||||||
|
21
sandbox/build.gradle.kts
Normal file
21
sandbox/build.gradle.kts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import ru.landgrafhomyak.kotlin.kmp_gradle_build_helper.plugin.xomrk
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
maven("https://maven.landgrafhomyak.ru/")
|
||||||
|
}
|
||||||
|
|
||||||
|
xomrk {
|
||||||
|
kotlin {
|
||||||
|
jvm {}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
jvmMain {
|
||||||
|
dependencies {
|
||||||
|
implementation(project(":"))
|
||||||
|
implementation("org.xerial:sqlite-jdbc:3.49.1.0")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
19
sandbox/src/commonMain/kotlin/main.kt
Normal file
19
sandbox/src/commonMain/kotlin/main.kt
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import java.sql.DriverManager
|
||||||
|
import ru.langrafhomyak.db.jdbc_resources_manager.PreparedStatementsCompilationPhantomCache
|
||||||
|
|
||||||
|
val someStmt = PreparedStatementsCompilationPhantomCache("SELECT * FROM sqlite_master")
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
for (i in 0..10) {
|
||||||
|
DriverManager.getConnection("jdbc:sqlite::memory:").use { connection ->
|
||||||
|
someStmt.preparedStatementForConnection(connection).use { ps ->
|
||||||
|
ps.executeQuery().use { rs ->
|
||||||
|
while (rs.next()) {
|
||||||
|
println(rs.getString(0))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.gc()
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,3 @@
|
|||||||
plugins {
|
rootProject.name = "jdbc-resources-manager"
|
||||||
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
|
|
||||||
}
|
include(":sandbox")
|
||||||
rootProject.name = "jdbc-resources-manager"
|
|
@ -23,7 +23,7 @@ public class PreparedStatementsCompilationPhantomCache /*implements ReadOnlyProp
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
PreparedStatement preparedStatementForConnection(@NotNull Connection connection) throws SQLException {
|
public PreparedStatement preparedStatementForConnection(@NotNull Connection connection) throws SQLException {
|
||||||
final int key = identityHashCode(connection);
|
final int key = identityHashCode(connection);
|
||||||
ConnectionsMapNode node = this._map.get(key, connection);
|
ConnectionsMapNode node = this._map.get(key, connection);
|
||||||
if (node == null) {
|
if (node == null) {
|
||||||
|
@ -10,6 +10,9 @@ internal object _PhantomCacheCleanup {
|
|||||||
private val _virtualThreadProperty = "ru.langrafhomyak.db.jdbc_resources_manager._PhantomCacheCleanup.USE_VIRTUAL_THREAD"
|
private val _virtualThreadProperty = "ru.langrafhomyak.db.jdbc_resources_manager._PhantomCacheCleanup.USE_VIRTUAL_THREAD"
|
||||||
private val _referenceQueue = ReferenceQueue<Any?>()
|
private val _referenceQueue = ReferenceQueue<Any?>()
|
||||||
|
|
||||||
|
@Suppress("MAY_BE_CONST")
|
||||||
|
private val _threadName = "ru.langrafhomyak.db.jdbc_resources_manager._PhantomCacheCleanup"
|
||||||
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
if (this._isVirtualThreadsSupported() && System.getProperty(this._virtualThreadProperty)?.lowercase() != "false")
|
if (this._isVirtualThreadsSupported() && System.getProperty(this._virtualThreadProperty)?.lowercase() != "false")
|
||||||
@ -27,9 +30,6 @@ internal object _PhantomCacheCleanup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("MAY_BE_CONST")
|
|
||||||
private val _threadName = "ru.langrafhomyak.db.jdbc_resources_manager._PhantomCacheCleanup"
|
|
||||||
|
|
||||||
private fun _startSystemThreadBeforeJ21(): Thread {
|
private fun _startSystemThreadBeforeJ21(): Thread {
|
||||||
val t = Thread(
|
val t = Thread(
|
||||||
null,
|
null,
|
||||||
|
Reference in New Issue
Block a user