-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from touchlab/kpg/andriod_native_targets
Kpg/andriod native targets
- Loading branch information
Showing
14 changed files
with
2,125 additions
and
29 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
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
Large diffs are not rendered by default.
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
10 changes: 0 additions & 10 deletions
10
...lections/src/nativeCommonMain/kotlin/co/touchlab/stately/collections/SharedCollections.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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,4 +51,4 @@ actual class Lock actual constructor() { | |
|
||
actual inline fun Lock.close() { | ||
internalClose() | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
stately-concurrency/src/pthreadAndroidMain/kotlin/co/touchlab/stately/concurrency/Lock.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,54 @@ | ||
package co.touchlab.stately.concurrency | ||
|
||
import kotlinx.cinterop.Arena | ||
import kotlinx.cinterop.alloc | ||
import kotlinx.cinterop.ptr | ||
import platform.posix.PTHREAD_MUTEX_RECURSIVE | ||
import platform.posix.pthread_mutex_destroy | ||
import platform.posix.pthread_mutex_init | ||
import platform.posix.pthread_mutex_lock | ||
import platform.posix.pthread_mutex_t | ||
import platform.posix.pthread_mutex_trylock | ||
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 | ||
import kotlin.native.concurrent.freeze | ||
|
||
/** | ||
* A simple lock. | ||
* Implementations of this class should be re-entrant. | ||
*/ | ||
actual class Lock actual constructor() { | ||
private val arena = Arena() | ||
private val attr = arena.alloc<pthread_mutexattr_tVar>() | ||
private val mutex = arena.alloc<pthread_mutex_t>() | ||
|
||
init { | ||
pthread_mutexattr_init(attr.ptr) | ||
pthread_mutexattr_settype(attr.ptr, PTHREAD_MUTEX_RECURSIVE.toInt()) | ||
pthread_mutex_init(mutex.ptr, attr.ptr) | ||
freeze() | ||
} | ||
|
||
actual fun lock() { | ||
pthread_mutex_lock(mutex.ptr) | ||
} | ||
|
||
actual fun unlock() { | ||
pthread_mutex_unlock(mutex.ptr) | ||
} | ||
|
||
actual fun tryLock(): Boolean = pthread_mutex_trylock(mutex.ptr) == 0 | ||
|
||
fun internalClose() { | ||
pthread_mutex_destroy(mutex.ptr) | ||
pthread_mutexattr_destroy(attr.ptr) | ||
arena.clear() | ||
} | ||
} | ||
|
||
actual inline fun Lock.close() { | ||
internalClose() | ||
} |
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
1 change: 0 additions & 1 deletion
1
...so-collections/src/commonTest/kotlin/co/touchlab/stately/collections/IsoArrayDequeTest.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 |
---|---|---|
@@ -1,6 +1,5 @@ | ||
package co.touchlab.stately.collections | ||
|
||
class IsoArrayDequeTest : IsoMutableListTest() { | ||
@UseExperimental(ExperimentalStdlibApi::class) | ||
override fun defaultCollection(): IsoMutableCollection<SomeData> = IsoArrayDeque<SomeData>() | ||
} |
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