Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"ResourceSupervisor" #3376

Open
armanbilge opened this issue Jan 18, 2023 · 1 comment
Open

"ResourceSupervisor" #3376

armanbilge opened this issue Jan 18, 2023 · 1 comment

Comments

@armanbilge
Copy link
Member

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 :)

@armanbilge
Copy link
Member Author

Some overlap with:

This was referenced Apr 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant