-
-
Notifications
You must be signed in to change notification settings - Fork 566
Open
Labels
Description
trait Manager[F[_], K, V] {
def +=(pair: (K, Resource[F, V])): F[Unit]
def -=(key: K): F[Unit]
def apply(key: K): F[Option[V]]
def join(key: K): F[V]
}
object Manager {
def apply[F[_]: Sync, K, V]: Resource[F, Manager[F, K, V]] = ???
}The idea here is that it's often useful to have a concurrent map-like data structure which manages Resource lifecycles for you, indexed by some key (so you can retrieve the results). These resources can be submitted (via +=) and will be evaluated in background, with their value stored in the map once complete. Removing the key from the map would close the resource scope. Similarly, closing the resource scope on the Manager would close all constituent Resources and cancel any outstanding computations.
Reactions are currently unavailable