All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jvmMain.arrow.fx.coroutines.predef-test-jvm.kt Maven / Gradle / Ivy

package arrow.fx.coroutines

import arrow.core.continuations.AtomicRef
import java.util.concurrent.ThreadFactory
import kotlin.coroutines.CoroutineContext

public val singleThreadName: String = "single"
public val single: Resource = Resource.singleThreadContext(singleThreadName)

public val threadName: suspend () -> String =
  { Thread.currentThread().name }

public class NamedThreadFactory(private val mkName: (Int) -> String) : ThreadFactory {
  private val count = AtomicRef(0)
  override fun newThread(r: Runnable): Thread =
    Thread(r, mkName(count.get()))
      .apply { isDaemon = true }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy