-
Notifications
You must be signed in to change notification settings - Fork 560
Open
Labels
Description
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 :)
mtomko, bplommer, Jasper-M, ghostbuster91 and kubukoz