Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kpg/nmm native driver #3177

Merged
merged 15 commits into from
May 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/PR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ jobs:
if: matrix.os == 'macOS-latest' && matrix.job == 'test'
run: ./gradlew iosX64Test --stacktrace

- name: Run ios tests with strict memory model
if: matrix.os == 'macOS-latest' && matrix.job == 'test'
run: ./gradlew iosX64Test -Pkotlin.native.binary.memoryModel=strict --stacktrace

# Build the sample
- name: Build the sample
if: matrix.os == 'macOS-latest' && matrix.job == 'gradle-plugin-tests'
Expand Down
7 changes: 7 additions & 0 deletions docs/native_sqlite/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ kotlin {
val driver: SqlDriver = NativeSqliteDriver(Database.Schema, "test.db")
```

### Kotlin/Native Memory Models

The SQLDelight native driver is compatible with both the original strict memory model and the updated
memory model. However, it is optimized for the new memory model, and as most of the official Jetbrains
libraries will be gradually dropping support for the strict memory model, support for the strict
memory model may be deprecated or removed in future releases.

{% include 'common/index_queries.md' %}

## Reader Connection Pools
Expand Down
8 changes: 5 additions & 3 deletions drivers/native-driver/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ kotlin {
dependsOn(commonMain)
dependencies {
api deps.sqliter
implementation deps.stately.core
}
}
nativeTest {
Expand All @@ -52,9 +51,12 @@ kotlin {
implementation project(':drivers:driver-test')
}
}
nativeDarwinMain{
nativeLinuxLikeMain {
dependsOn(nativeMain)
}
nativeDarwinMain{
dependsOn(nativeLinuxLikeMain)
}
mingwMain{
dependsOn(nativeMain)
}
Expand All @@ -65,7 +67,7 @@ kotlin {
dependsOn(mingwMain)
}
linuxMain{
dependsOn(nativeMain)
dependsOn(nativeLinuxLikeMain)
}
}

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import kotlinx.cinterop.alloc
import kotlinx.cinterop.free
import kotlinx.cinterop.nativeHeap
import kotlinx.cinterop.ptr
import platform.posix.PTHREAD_MUTEX_RECURSIVE
import platform.posix.pthread_cond_destroy
import platform.posix.pthread_cond_init
import platform.posix.pthread_cond_signal
Expand All @@ -15,11 +16,21 @@ import platform.posix.pthread_mutex_init
import platform.posix.pthread_mutex_lock
import platform.posix.pthread_mutex_tVar
import platform.posix.pthread_mutex_unlock
import platform.posix.pthread_mutexattr_destroy
import platform.posix.pthread_mutexattr_init
import platform.posix.pthread_mutexattr_settype
import platform.posix.pthread_mutexattr_tVar

internal actual class PoolLock actual constructor() {
internal actual class PoolLock actual constructor(reentrant: Boolean) {
private val isActive = AtomicBoolean(true)
private val attr = nativeHeap.alloc<pthread_mutexattr_tVar>()
.apply {
pthread_mutexattr_init(ptr)
if (reentrant)
pthread_mutexattr_settype(ptr, PTHREAD_MUTEX_RECURSIVE.toInt())
}
private val mutex = nativeHeap.alloc<pthread_mutex_tVar>()
.apply { pthread_mutex_init(ptr, null) }
.apply { pthread_mutex_init(ptr, attr.ptr) }
private val cond = nativeHeap.alloc<pthread_cond_tVar>()
.apply { pthread_cond_init(ptr, null) }

Expand Down Expand Up @@ -48,8 +59,10 @@ internal actual class PoolLock actual constructor() {
if (isActive.compareAndSet(expected = true, new = false)) {
pthread_cond_destroy(cond.ptr)
pthread_mutex_destroy(mutex.ptr)
pthread_mutexattr_destroy(attr.ptr)
nativeHeap.free(cond)
nativeHeap.free(mutex)
nativeHeap.free(attr)
return true
}

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading