Skip to content

"ResourceSupervisor" #3376

@armanbilge

Description

@armanbilge

This is an idea @TimWSpence and I cooked up once on Discord, starting from typelevel/fs2#2300 (comment).

The idea is very similar to the existing Supervisor which allows to start a fiber, and bind its lifecycle to some outer scope. Here, we want to allocate a Resource and bind its lifecycle to the outer scope.

ResourceSupervisor[F].use { supervisor =>
  resourceA.allocateSupervised(supervisor).flatMap { (a, release) =>
    // do stuff
  }
}

allocateSupervised (or superviseAllocated ?) would work like allocated, except in case the release is not invoked for some reason, it will be cleaned up once the supervisor scope ends.

tl;dr start is to allocated what supervise is to (we need something here :)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions