Skip to content

Commit 9d202b5

Browse files
authored
Merge pull request #67 from touchlab/kpg/visibility_and_api
Kpg/visibility and api
2 parents e95a128 + 3efe092 commit 9d202b5

File tree

21 files changed

+55
-46
lines changed

21 files changed

+55
-46
lines changed

settings.gradle.kts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ rootProject.name = "sqliter"
33
include(":sqliter-driver")
44

55
pluginManagement {
6-
repositories {
7-
google()
8-
gradlePluginPortal()
9-
maven(url = "https://oss.sonatype.org/content/repositories/snapshots/")
10-
}
116
val KOTLIN_VERSION: String by settings
127
plugins {
138
kotlin("multiplatform") version KOTLIN_VERSION

sqliter-driver/src/appleMain/kotlin/co/touchlab/sqliter/concurrency/Lock.kt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,18 @@ package co.touchlab.sqliter.concurrency
22

33
import platform.Foundation.NSRecursiveLock
44

5-
actual typealias Lock = NSRecursiveLock
5+
internal actual class Lock actual constructor() {
6+
private val l = NSRecursiveLock()
7+
actual fun lock() {
8+
l.lock()
9+
}
10+
11+
actual fun unlock() {
12+
l.unlock()
13+
}
14+
15+
actual fun tryLock(): Boolean = l.tryLock()
16+
}
617

718
@Suppress("NOTHING_TO_INLINE")
8-
actual inline fun Lock.close() {}
19+
internal actual inline fun Lock.close() {}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package co.touchlab.sqliter.util
22

3-
actual fun usleep(seconds: UInt) {
3+
internal actual fun usleep(seconds: UInt) {
44
platform.posix.usleep(seconds)
55
}

sqliter-driver/src/linuxX64Main/kotlin/co/touchlab/sqliter/concurrency/Lock.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import platform.posix.*
1010
* A simple lock.
1111
* Implementations of this class should be re-entrant.
1212
*/
13-
actual class Lock actual constructor() {
13+
internal actual class Lock actual constructor() {
1414
private val arena = Arena()
1515
private val attr = arena.alloc<pthread_mutexattr_t>()
1616
private val mutex = arena.alloc<pthread_mutex_t>()
@@ -39,6 +39,6 @@ actual class Lock actual constructor() {
3939
}
4040
}
4141

42-
actual inline fun Lock.close() {
42+
internal actual inline fun Lock.close() {
4343
internalClose()
4444
}

sqliter-driver/src/linuxX64Main/kotlin/co/touchlab/sqliter/util/usleep.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ package co.touchlab.sqliter.util
33
/**
44
* Wrapper for platform.posix.usleep
55
*/
6-
actual fun usleep(seconds: UInt) {
6+
internal actual fun usleep(seconds: UInt) {
77
platform.posix.usleep(seconds)
88
}

sqliter-driver/src/mingwMain/kotlin/co/touchlab/sqliter/util/usleep.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ package co.touchlab.sqliter.util
33
/**
44
* Wrapper for platform.posix.usleep
55
*/
6-
actual fun usleep(seconds: UInt) {
6+
internal actual fun usleep(seconds: UInt) {
77
platform.posix.usleep(seconds)
88
}

sqliter-driver/src/mingwX64Main/kotlin/co/touchlab/sqliter/concurrency/Lock.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import platform.posix.pthread_mutexattr_tVar
2020
* A simple lock.
2121
* Implementations of this class should be re-entrant.
2222
*/
23-
actual class Lock actual constructor() {
23+
internal actual class Lock actual constructor() {
2424
private val arena = Arena()
2525
private val attr = arena.alloc<pthread_mutexattr_tVar>()
2626
private val mutex = arena.alloc<pthread_mutex_tVar>()
@@ -49,6 +49,6 @@ actual class Lock actual constructor() {
4949
}
5050
}
5151

52-
actual inline fun Lock.close() {
52+
internal actual inline fun Lock.close() {
5353
internalClose()
5454
}

sqliter-driver/src/mingwX86Main/kotlin/co/touchlab/sqliter/concurrency/Lock.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import platform.posix.pthread_mutexattr_tVar
2020
* A simple lock.
2121
* Implementations of this class should be re-entrant.
2222
*/
23-
actual class Lock actual constructor() {
23+
internal actual class Lock actual constructor() {
2424
private val arena = Arena()
2525
private val attr = arena.alloc<pthread_mutexattr_tVar>()
2626
private val mutex = arena.alloc<pthread_mutex_tVar>()
@@ -49,6 +49,6 @@ actual class Lock actual constructor() {
4949
}
5050
}
5151

52-
actual inline fun Lock.close() {
52+
internal actual inline fun Lock.close() {
5353
internalClose()
5454
}

sqliter-driver/src/nativeCommonMain/kotlin/co/touchlab/sqliter/DatabaseConfiguration.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package co.touchlab.sqliter
1818

1919
import co.touchlab.sqliter.interop.Logger
2020

21-
2221
data class DatabaseConfiguration(
2322
val name: String?,
2423
val version: Int,

sqliter-driver/src/nativeCommonMain/kotlin/co/touchlab/sqliter/concurrency/ConcurrentDatabaseConnection.kt

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ import co.touchlab.sqliter.DatabaseConnection
2121
import co.touchlab.sqliter.FieldType
2222
import co.touchlab.sqliter.Statement
2323

24-
class ConcurrentDatabaseConnection(private val delegateConnection:DatabaseConnection):DatabaseConnection{
24+
internal class ConcurrentDatabaseConnection(private val delegateConnection: DatabaseConnection) : DatabaseConnection {
2525
private val accessLock = Lock()
2626

2727
override fun rawExecSql(sql: String) = accessLock.withLock { delegateConnection.rawExecSql(sql) }
2828

29-
override fun createStatement(sql: String): Statement = accessLock.withLock { ConcurrentStatement(delegateConnection.createStatement(sql)) }
29+
override fun createStatement(sql: String): Statement =
30+
accessLock.withLock { ConcurrentStatement(delegateConnection.createStatement(sql)) }
3031

3132
override fun beginTransaction() = accessLock.withLock { delegateConnection.beginTransaction() }
3233

@@ -39,7 +40,7 @@ class ConcurrentDatabaseConnection(private val delegateConnection:DatabaseConnec
3940
override val closed: Boolean
4041
get() = delegateConnection.closed
4142

42-
inner class ConcurrentCursor(private val delegateCursor: Cursor):Cursor{
43+
inner class ConcurrentCursor(private val delegateCursor: Cursor) : Cursor {
4344
override fun next(): Boolean = accessLock.withLock { delegateCursor.next() }
4445

4546
override fun isNull(index: Int): Boolean = accessLock.withLock { delegateCursor.isNull(index) }
@@ -66,7 +67,7 @@ class ConcurrentDatabaseConnection(private val delegateConnection:DatabaseConnec
6667

6768
}
6869

69-
inner class ConcurrentStatement(internal val delegateStatement:Statement):Statement{
70+
inner class ConcurrentStatement(internal val delegateStatement: Statement) : Statement {
7071
override fun execute() = accessLock.withLock { delegateStatement.execute() }
7172

7273
override fun executeInsert(): Long = accessLock.withLock { delegateStatement.executeInsert() }
@@ -83,14 +84,19 @@ class ConcurrentDatabaseConnection(private val delegateConnection:DatabaseConnec
8384

8485
override fun bindNull(index: Int) = accessLock.withLock { delegateStatement.bindNull(index) }
8586

86-
override fun bindLong(index: Int, value: Long) = accessLock.withLock { delegateStatement.bindLong(index, value) }
87+
override fun bindLong(index: Int, value: Long) =
88+
accessLock.withLock { delegateStatement.bindLong(index, value) }
8789

88-
override fun bindDouble(index: Int, value: Double) = accessLock.withLock { delegateStatement.bindDouble(index, value) }
90+
override fun bindDouble(index: Int, value: Double) =
91+
accessLock.withLock { delegateStatement.bindDouble(index, value) }
8992

90-
override fun bindString(index: Int, value: String) = accessLock.withLock { delegateStatement.bindString(index, value) }
93+
override fun bindString(index: Int, value: String) =
94+
accessLock.withLock { delegateStatement.bindString(index, value) }
9195

92-
override fun bindBlob(index: Int, value: ByteArray) = accessLock.withLock { delegateStatement.bindBlob(index, value) }
96+
override fun bindBlob(index: Int, value: ByteArray) =
97+
accessLock.withLock { delegateStatement.bindBlob(index, value) }
9398

94-
override fun bindParameterIndex(paramName: String): Int = accessLock.withLock { delegateStatement.bindParameterIndex(paramName) }
99+
override fun bindParameterIndex(paramName: String): Int =
100+
accessLock.withLock { delegateStatement.bindParameterIndex(paramName) }
95101
}
96102
}

0 commit comments

Comments
 (0)