Common Thread
class (and snychronization primitives) for Kotlin/Multiplatform.
This allows true, pure parallelism in Kotlin where controlling an OS thread directly is feasable.
The library also offers various utilities and integration with other libraries.
- Windows
- Linux
- macOS
- iOS
- watchOS
- tvOS
- Android
- Android Native
- JVM
Thread
as a general purpose wrapper around system threadsjava.lang.Thread
on JVM/Android- libpthread on Kotlin/Native targets
- Unified support for thread names
- Unified support for thread IDs
Mutex
as a simple mutex implementation- Lock guards as integration with RAkII
SharedMutex
as a reentrant read-write lock implementation- Lock guards as integration with RAkII
Executor
interface for bridging different APIsThreadPool
as a simple work-stealing thread pool implementation- Default implementation of
Executor
- Default implementation of
Future
interface for unifying awaitable objectsCompletableFuture
type with atomic state as a defaultFuture
implementation- Create uncompleted futures with any default value
- Create a value supplying task from an
Executor
and a block
- java.util.concurrent
integration
- Use any filament
Executor
as a JVMExecutor
- Use any filament
- kotlinx.coroutines integration
- Use any
Executor
as aCoroutineDispatcher
- Use any
Future<T>
as aDeferred<T>
and vice versa - Use
CompletableFuture.asyncSuspend
to create awaitable objects from a suspend block - Use
Future.awaitSuspend
to await any future by yielding the coroutine
- Use any
More features may be added in the future. Contributions are welcome! :)
First, add the official Karma Krafts maven repository to your settings.gradle.kts
:
pluginManagement {
repositories {
// Snapshots are available from the Karma Krafts repository or Maven Central Snapshots
maven("https://files.karmakrafts.dev/maven")
maven("https://central.sonatype.com/repository/maven-snapshots")
// Releases are mirrored to the central M2 repository
mavenCentral()
}
}
dependencyResolutionManagement {
repositories {
// Snapshots are available from the Karma Krafts repository or Maven Central Snapshots
maven("https://files.karmakrafts.dev/maven")
maven("https://central.sonatype.com/repository/maven-snapshots")
// Releases are mirrored to the central M2 repository
mavenCentral()
}
}
Then add a dependency on the library in your buildscript:
kotlin {
commonMain {
dependencies {
implementation("dev.karmakrafts.filament:filament:<version>")
}
}
}