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.
Processoras a general purpose abstraction for accessing CPU related information- Support for querying the logical core count
Threadas a general purpose wrapper around system threadsjava.lang.Threadon JVM/Android- libpthread on Kotlin/Native targets
- Unified support for thread names
- Unified support for thread IDs
- Support for setting thread affinity (pinning)
Mutexas a simple mutex implementationSharedMutexas a reentrant read-write lock implementationExecutorinterface for bridging different APIsThreadPoolas a simple work-stealing thread pool implementation- Default implementation of
Executor
- Default implementation of
Futureinterface for unifying awaitable objectsCompletableFuturetype with atomic state as a defaultFutureimplementation- Create uncompleted futures with any default value
- Create a value supplying task from an
Executorand a block
- java.util.concurrent
integration
- Use any filament
Executoras a JVMExecutor
- Use any filament
- kotlinx.coroutines integration
- Use any
Executoras aCoroutineDispatcher - Use any
Deferred<T>as aFuture<T> - Use
CompletableFuture.asyncSuspendto create awaitable objects from a suspend block - Use
Future.awaitSuspendto 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:
dependencyResolutionManagement {
repositories {
mavenCentral()
}
}Then add a dependency on the library in your buildscript:
kotlin {
commonMain {
dependencies {
implementation("dev.karmakrafts.filament:filament-core:<version>")
}
}
}