//arrow-fx-coroutines/arrow.fx.coroutines/Resource/Companion

Companion

common object Companion

Functions

Name Summary
defer common fun <A> defer(f: suspend () -> Resource<A>): Resource<A>
invoke common operator fun <A> invoke(acquire: suspend () -> A, release: suspend (A, ExitCase) -> Unit): Resource<A>
Construct a Resource from a allocating function acquire and a release function release.
just common fun <A> just(r: A): Resource<A>
Create a Resource from a pure value A.

Extensions

Name Summary
fromAutoCloseable jvm fun <A : AutoCloseable> Resource.Companion.fromAutoCloseable(f: suspend () -> A): Resource<A>
Creates a Resource from an AutoCloseable, which uses AutoCloseable.close for releasing.
fromCloseable jvm fun <A : Closeable> Resource.Companion.fromCloseable(f: suspend () -> A): Resource<A>
Creates a Resource from an Closeable, which uses Closeable.close for releasing.
fromExecutor jvm fun Resource.Companion.fromExecutor(f: suspend () -> ExecutorService): Resource<CoroutineContext>
Creates a single threaded CoroutineContext as a Resource. Upon release an orderly shutdown of the ExecutorService takes place in which previously submitted tasks are executed, but no new tasks will be accepted.
singleThreadContext jvm fun Resource.Companion.singleThreadContext(name: String): Resource<CoroutineContext>
Creates a single threaded CoroutineContext as a Resource. Upon release an orderly shutdown of the ExecutorService takes place in which previously submitted tasks are executed, but no new tasks will be accepted.

Do you like Arrow?

Arrow Org
<