- Companion:
- class
- Source:
- Resource.scala
Type members
Classlikes
Resource
data constructor that wraps an effect allocating a resource, along with its
finalizers.
Resource
data constructor that wraps an effect allocating a resource, along with its
finalizers.
- Source:
- Resource.scala
Resource
data constructor that encodes the flatMap
operation.
Resource
data constructor that encodes the flatMap
operation.
- Source:
- Resource.scala
Type for signaling the exit condition of an effectful computation, that may either succeed, fail with an error or get canceled.
Type for signaling the exit condition of an effectful computation, that may either succeed, fail with an error or get canceled.
The types of exit signals are:
- Companion:
- object
- Source:
- Resource.scala
- Source:
- Resource.scala
Types
Inherited types
The names of the product elements
The names of the product elements
- Inherited from:
- Mirror
- Source:
- Mirror.scala
Value members
Concrete methods
Creates a resource from an allocating effect.
Creates a resource from an allocating effect.
- Type parameters:
- A
the type of the resource
- F
the effect type in which the resource is acquired and released
- Value parameters:
- resource
an effect that returns a tuple of a resource and an effect to release it
- See also:
make for a version that separates the needed resource with its finalizer tuple in two parameters
- Source:
- Resource.scala
Creates a resource from an allocating effect, with a finalizer that is able to distinguish between exit cases.
Creates a resource from an allocating effect, with a finalizer that is able to distinguish between exit cases.
- Type parameters:
- A
the type of the resource
- F
the effect type in which the resource is acquired and released
- Value parameters:
- resource
an effect that returns a tuple of a resource and an effectful function to release it
- See also:
makeCase for a version that separates the needed resource with its finalizer tuple in two parameters
- Source:
- Resource.scala
Creates a resource from an allocating effect, with a finalizer that is able to distinguish between exit cases.
Creates a resource from an allocating effect, with a finalizer that is able to distinguish between exit cases.
The action takes a Poll[F]
to allow for interruptible acquires, which is most often
useful when acquiring lock-like structure: it should be possible to interrupt a fiber
waiting on a lock, but if it does get acquired, release need to be guaranteed.
Note that in this case the acquire action should know how to cleanup after itself in case
it gets canceled, since Resource will only guarantee release when acquire succeeds and
fails (and when the actions in use
or flatMap
fail, succeed, or get canceled)
TODO make sure this api, which is more general than makeFull, doesn't allow for interruptible releases
- Type parameters:
- A
the type of the resource
- F
the effect type in which the resource is acquired and released
- Value parameters:
- resource
an effect that returns a tuple of a resource and an effectful function to release it, where acquisition can potentially be interrupted
- See also:
makeFull for a version that separates the needed resource with its finalizer tuple in two parameters
- Source:
- Resource.scala
Allocates two resources concurrently, and combines their results in a tuple.
Allocates two resources concurrently, and combines their results in a tuple.
- Source:
- Resource.scala
- Source:
- Resource.scala
Lifts an applicative into a resource. The resource has a no-op release. Preserves
interruptibility of fa
.
Lifts an applicative into a resource. The resource has a no-op release. Preserves
interruptibility of fa
.
- Value parameters:
- fa
the value to lift into a resource
- Source:
- Resource.scala
Creates a Resource by wrapping a Java AutoCloseable.
Creates a Resource by wrapping a Java AutoCloseable.
In most real world cases, implementors of AutoCloseable are blocking as well, so the close action runs in the blocking context.
- Type parameters:
- A
the type of the autocloseable resource
- F
the type of the effect
- Value parameters:
- F
the effect type in which the resource was acquired and will be released
- acquire
The effect with the resource to acquire.
- Returns:
a Resource that will automatically close after use
- Example:
import cats.effect._ import scala.io.Source def reader(data: String): Resource[IO, Source] = Resource.fromAutoCloseable(IO.blocking { Source.fromString(data) })
import cats.effect._ import scala.io.Source def reader[F[_]](data: String)(implicit F: Sync[F]): Resource[F, Source] = Resource.fromAutoCloseable(F.blocking { Source.fromString(data) })
- Source:
- Resource.scala
Lifts an applicative into a resource as a FunctionK
. The resource has a no-op release.
Lifts an applicative into a resource as a FunctionK
. The resource has a no-op release.
- Source:
- Resource.scala
Creates a resource from an acquiring effect and a release function.
Creates a resource from an acquiring effect and a release function.
- Type parameters:
- A
the type of the resource
- F
the effect type in which the resource is acquired and released
- Value parameters:
- acquire
an effect to acquire a resource
- release
a function to effectfully release the resource returned by
acquire
- Source:
- Resource.scala
Creates a resource from an acquiring effect and a release function that can discriminate between different exit cases.
Creates a resource from an acquiring effect and a release function that can discriminate between different exit cases.
- Type parameters:
- A
the type of the resource
- F
the effect type in which the resource is acquired and released
- Value parameters:
- acquire
a function to effectfully acquire a resource
- release
a function to effectfully release the resource returned by
acquire
- Source:
- Resource.scala
Creates a resource from an acquiring effect and a release function that can discriminate between different exit cases.
Creates a resource from an acquiring effect and a release function that can discriminate between different exit cases.
The acquiring effect takes a Poll[F]
to allow for interruptible acquires, which is most
often useful when acquiring lock-like structures: it should be possible to interrupt a
fiber waiting on a lock, but if it does get acquired, release need to be guaranteed.
Note that in this case the acquire action should know how to cleanup after itself in case
it gets canceled, since Resource will only guarantee release when acquire succeeds and
fails (and when the actions in use
or flatMap
fail, succeed, or get canceled)
- Type parameters:
- A
the type of the resource
- F
the effect type in which the resource is acquired and released
- Value parameters:
- acquire
an effect to acquire a resource, possibly interruptibly
- release
a function to effectfully release the resource returned by
acquire
- Source:
- Resource.scala
Creates a resource from an acquiring effect and a release function that can discriminate between different exit cases.
Creates a resource from an acquiring effect and a release function that can discriminate between different exit cases.
The acquiring effect takes a Poll[F]
to allow for interruptible acquires, which is most
often useful when acquiring lock-like structures: it should be possible to interrupt a
fiber waiting on a lock, but if it does get acquired, release need to be guaranteed.
Note that in this case the acquire action should know how to cleanup after itself in case
it gets canceled, since Resource will only guarantee release when acquire succeeds and
fails (and when the actions in use
or flatMap
fail, succeed, or get canceled)
- Type parameters:
- A
the type of the resource
- F
the effect type in which the resource is acquired and released
- Value parameters:
- acquire
an effect to acquire a resource, possibly interruptibly
- release
a function to effectfully release the resource returned by
acquire
- Source:
- Resource.scala
Lifts a finalizer into a resource. The resource has a no-op allocation.
Lifts a finalizer into a resource. The resource has a no-op allocation.
- Source:
- Resource.scala
Creates a resource that allocates immediately without any effects, but calls release
when
closing, providing the the usage completed with.
Creates a resource that allocates immediately without any effects, but calls release
when
closing, providing the the usage completed with.
- Source:
- Resource.scala
Lifts a pure value into a resource. The resource has a no-op release.
Lifts a pure value into a resource. The resource has a no-op release.
- Value parameters:
- a
the value to lift into a resource
- Source:
- Resource.scala
Races the evaluation of two resource allocations and returns the result of the winner, except in the case of cancelation.
Races the evaluation of two resource allocations and returns the result of the winner, except in the case of cancelation.
- Source:
- Resource.scala
- Source:
- Resource.scala
Given a Resource
suspended in F[_]
, lifts it in the Resource
context.
Given a Resource
suspended in F[_]
, lifts it in the Resource
context.
- Source:
- Resource.scala
- Source:
- Resource.scala
A resource with a no-op allocation and a no-op release.
A resource with a no-op allocation and a no-op release.
- Source:
- Resource.scala
Deprecated methods
Deprecated and Inherited methods
- Deprecated
- Inherited from:
- ResourceFOInstances1 (hidden)
- Source:
- Resource.scala
Implicits
Implicits
- Source:
- Resource.scala
- Source:
- Resource.scala
- Source:
- Resource.scala
Inherited implicits
- Inherited from:
- ResourceHOInstances0 (hidden)
- Source:
- Resource.scala
- Inherited from:
- ResourceHOInstances2 (hidden)
- Source:
- Resource.scala
- Inherited from:
- ResourceHOInstances2 (hidden)
- Source:
- Resource.scala
- Inherited from:
- ResourceHOInstances3 (hidden)
- Source:
- Resource.scala
- Inherited from:
- ResourceHOInstances4 (hidden)
- Source:
- Resource.scala
- Inherited from:
- ResourceFOInstances1 (hidden)
- Source:
- Resource.scala
- Inherited from:
- ResourceHOInstances0 (hidden)
- Source:
- Resource.scala
- Inherited from:
- ResourceHOInstances1 (hidden)
- Source:
- Resource.scala
- Inherited from:
- ResourceHOInstances1 (hidden)
- Source:
- Resource.scala