If you don't know enough of those principles from somewhere else then the docs confuse you
note that when the docs are just about general principles, people struggle with lack of practical how-tos. You need both ideally, and that's very time consuming
tutorials, how-to guides, technical reference and explanation
ContextShift[IO]
without having to mixin IOApp
? I'm working on introducing cats-effect into an Akka codebase and would like to use specific execution contexts to create different ContextShift[IO]
. It seems IOContextShift
is there but it's part of cats.effect.internals
package
type Thingy
def x[F[_]: Concurrent]: Resource[F, MVar[F, Thingy]] =
for {
sem <- Resource.liftF(Semaphore[F](1L))
mvar <- Resource.liftF(MVar.empty[F, Thingy])
fiber <- // construct a fiber that uses the semaphore and mvar and cancels when the resource is closed
} yield mvar
fiber
would be doing something like Stream.repeatEval(update(mvar)).metered(5.minutes)
Thingy
? if you do, then hold
will fit your use case perfectly. If you don't, you can use most of the same tools that are under hold
(concurrently
mostly) and then compile.resource
to have a Resource
MVar
isn't quite right, because we're not waiting for someone to take a value out.