Packages

final case class Suspend[F[_], A](resource: F[Resource[F, A]]) extends Resource[F, A] with Product with Serializable

Resource data constructor that suspends the evaluation of another resource value.

Source
Resource.scala
Linear Supertypes
Serializable, Product, Equals, Resource[F, A], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Suspend
  2. Serializable
  3. Product
  4. Equals
  5. Resource
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new Suspend(resource: F[Resource[F, A]])

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def allocated[G[x] >: F[x], B >: A](implicit F: Bracket[[α$7$]G[α$7$], Throwable]): G[(B, G[Unit])]

    Given a Resource, possibly built by composing multiple Resources monadically, returns the acquired resource, as well as an action that runs all the finalizers for releasing it.

    Given a Resource, possibly built by composing multiple Resources monadically, returns the acquired resource, as well as an action that runs all the finalizers for releasing it.

    If the outer F fails or is interrupted, allocated guarantees that the finalizers will be called. However, if the outer F succeeds, it's up to the user to ensure the returned F[Unit] is called once A needs to be released. If the returned F[Unit] is not called, the finalizers will not be run.

    For this reason, this is an advanced and potentially unsafe api which can cause a resource leak if not used correctly, please prefer use as the standard way of running a Resource program.

    Use cases include interacting with side-effectful apis that expect separate acquire and release actions (like the before and after methods of many test frameworks), or complex library code that needs to modify or move the finalizer for an existing resource.

    Definition Classes
    Resource
  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  7. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  8. def evalMap[G[x] >: F[x], B](f: (A) => G[B])(implicit F: Applicative[[α$8$]G[α$8$]]): Resource[[α$9$]G[α$9$], B]

    Applies an effectful transformation to the allocated resource.

    Applies an effectful transformation to the allocated resource. Like a flatMap on F[A] while maintaining the resource context

    Definition Classes
    Resource
  9. def evalTap[G[x] >: F[x], B](f: (A) => G[B])(implicit F: Applicative[[α$10$]G[α$10$]]): Resource[[α$11$]G[α$11$], A]

    Applies an effectful transformation to the allocated resource.

    Applies an effectful transformation to the allocated resource. Like a flatTap on F[A] while maintaining the resource context

    Definition Classes
    Resource
  10. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  11. def flatMap[G[x] >: F[x], B](f: (A) => Resource[[α$3$]G[α$3$], B]): Resource[[α$4$]G[α$4$], B]

    Implementation for the flatMap operation, as described via the cats.Monad type class.

    Implementation for the flatMap operation, as described via the cats.Monad type class.

    Definition Classes
    Resource
  12. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  13. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  14. def map[G[x] >: F[x], B](f: (A) => B)(implicit F: Applicative[[α$5$]G[α$5$]]): Resource[[α$6$]G[α$6$], B]

    Given a mapping function, transforms the resource provided by this Resource.

    Given a mapping function, transforms the resource provided by this Resource.

    This is the standard Functor.map.

    Definition Classes
    Resource
  15. def mapK[G[x] >: F[x], H[_]](f: ~>[G, H])(implicit D: Defer[H], G: Applicative[H]): Resource[H, A]

    Given a natural transformation from F to G, transforms this Resource from effect F to effect G.

    Given a natural transformation from F to G, transforms this Resource from effect F to effect G.

    Definition Classes
    Resource
  16. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  17. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  18. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  19. def parZip[G[x] >: F[x], B](that: Resource[[α$1$]G[α$1$], B])(implicit arg0: Sync[G], arg1: Parallel[G]): Resource[[α$2$]G[α$2$], (A, B)]

    Allocates two resources concurrently, and combines their results in a tuple.

    Allocates two resources concurrently, and combines their results in a tuple.

    The finalizers for the two resources are also run concurrently with each other, but within _each_ of the two resources, nested finalizers are run in the usual reverse order of acquisition.

    Note that Resource also comes with a cats.Parallel instance that offers more convenient access to the same functionality as parZip, for example via parMapN:

     def mkResource(name: String) = {
       val acquire =
         IO(scala.util.Random.nextInt(1000).millis).flatMap(IO.sleep) *>
         IO(println(s"Acquiring $$name")).as(name)
    
       val release = IO(println(s"Releasing $$name"))
       Resource.make(acquire)(release)
     }
    
    val r = (mkResource("one"), mkResource("two"))
               .parMapN((s1, s2) => s"I have $s1 and $s2")
               .use(msg => IO(println(msg)))
    Definition Classes
    Resource
  20. def productElementNames: Iterator[String]
    Definition Classes
    Product
  21. val resource: F[Resource[F, A]]
  22. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  23. def use[G[x] >: F[x], B](f: (A) => G[B])(implicit F: Bracket[[α$0$]G[α$0$], Throwable]): G[B]

    Allocates a resource and supplies it to the given function.

    Allocates a resource and supplies it to the given function. The resource is released as soon as the resulting F[B] is completed, whether normally or as a raised error.

    f

    the function to apply to the allocated resource

    returns

    the result of applying [F] to

    Definition Classes
    Resource
  24. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  25. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  26. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from Resource[F, A]

Inherited from AnyRef

Inherited from Any

Ungrouped