
org.sheinbergon.needle.knitter.PinnedThreads.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of needle-knitter Show documentation
Show all versions of needle-knitter Show documentation
Feature-rich CPU affinity for the JVM - Kotlin extensions
@file:JvmName("PinnedThreadsKt")
package org.sheinbergon.needle.knitter
import org.sheinbergon.needle.AffinityDescriptor
import org.sheinbergon.needle.PinnedThread
private const val `0L` = 0L
fun pinnedThread(
start: Boolean = true,
isDaemon: Boolean = false,
contextClassLoader: ClassLoader? = null,
name: String? = null,
affinity: AffinityDescriptor = AffinityDescriptor.from(`0L`),
block: () -> Unit
): PinnedThread {
val pinnedThread = PinnedThread(block::invoke, affinity)
if (isDaemon) {
pinnedThread.isDaemon = true
}
if (name != null) {
pinnedThread.name = name
}
if (contextClassLoader != null) {
pinnedThread.contextClassLoader = contextClassLoader
}
if (start) {
pinnedThread.start()
}
return pinnedThread
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy