~zainab/blog

bbafd163a1fc6ccb9fe713345ac70e2d31101ba4 — zainab-ali 6 months ago 0034c2f
Corrections to cats-effect-ioruntime post
M src/chapters/2022-02-12-cats-effect-ioruntime/abstract.html.pm => src/chapters/2022-02-12-cats-effect-ioruntime/abstract.html.pm +4 -4
@@ 1,13 1,13 @@
#lang pollen

◊(define-meta time (1 0))
◊(define-meta title "Understanding thread pools with the cats-effect IORuntime")
◊(define-meta title "Understanding thread pools through cats-effect")

◊abstract{
◊code-inline{Could not find an implicit IORuntime.} is a common error
when using cats-effect. But what is an ◊code-inline{IORuntime}, and
how should we use it? In this tutorial, you’ll use cats-effect 3 to
explore the basics of parallelism, thread pools and blocking. You’ll
see why the cats-effect ◊code-inline{IORuntime.global} is the best
model for your application.
explore the basics of thread pools, execution contexts, and
blocking. You’ll see why the cats-effect
◊code-inline{IORuntime.global} is the best model for your application.
}

M src/chapters/2022-02-12-cats-effect-ioruntime/overview.html.pm => src/chapters/2022-02-12-cats-effect-ioruntime/overview.html.pm +13 -3
@@ 6,7 6,7 @@

◊headline2{You will learn}
◊items{
  ◊item{ How to run computations in parallel using cats-effect 3.}
  ◊item{The difference between blocking and compute‑intensive operations.}
  ◊item{What a thread pool is; and about bounded and unbounded thread pools.}
  ◊item{What the ◊code-inline{IORuntime} is made of, and why
  cats-effect 3 structures it the way it does.}


@@ 18,9 18,19 @@
◊items{
◊item{A bit about the cats effect ◊code-inline{IO} datatype, to the
extent that you can create and run an ◊code-inline{IO}.}
◊item{A bit about concurrency such that you’re not too surprised by
parallel computations.}
}

◊p{You’ll get the most out of this if cats-effect is your first
experience of parallel computation. You’re not too sure what thread
pools are (or threads, for that matter), and aren’t as confident in
experience of threads. You’re not too sure what thread
pools are (or execution contexts, for that matter), and aren’t as confident in
using them as you’d like.}

◊headline2{Some caveats}

◊p{This tutorial won’t teach you how to ◊em{use} cats-effect — and you
certainly don’t need to understand thread pools in order to
use it. If you’re still getting started with ◊code-inline{IO} and the
basics of parallelism, why not head over to the ◊external-link[#:href
"https://typelevel.org/cats-effect/docs/tutorial"]{cats-effect tutorial} instead?}

M src/chapters/2022-02-12-cats-effect-ioruntime/recap.html.pm => src/chapters/2022-02-12-cats-effect-ioruntime/recap.html.pm +8 -1
@@ 1,6 1,5 @@
#lang pollen


◊p{To summarize:}

◊items{


@@ 35,3 34,11 @@ default. You can tap into the blocking pool using
  threads in your operating system? Convert to Linux and play with its
  processes!}

◊headline2{Credits}

◊p{Many thanks to ◊external-link[#:href
"https://github.com/SystemFW"]{Fabio Labella} and
◊external-link[#:href "https://gist.github.com/djspiewak"]{Daniel
Spiewak} for giving this a reassuring read.}



M src/chapters/2022-02-12-cats-effect-ioruntime/the-IORuntime.html.pm => src/chapters/2022-02-12-cats-effect-ioruntime/the-IORuntime.html.pm +12 -4
@@ 17,10 17,18 @@ do any calculations. Blocking tasks are rare, and you should be very
reluctant to write one.}

◊note[#:title "By the way"]{
We’re using ◊code-inline{Thread.sleep} as an educational example. If
you ever need to pause in your own code, use
◊code-inline{IO.sleep}. This ◊em{doesn’t} block a thread, but you can
ponder that mystery later.
◊p{
We’re using ◊code-inline{Thread.sleep} as an educational example of a
blocking operation. If you ever need to 
pause in your own code, use ◊code-inline{IO.sleep}. This ◊em{doesn’t}
block a thread, but you can ponder that mystery later.
}
◊p{
Real-world blocking, such as writing to disk
or reading from a socket, tends to be much more nuanced than
◊code-inline{Thread.sleep}, and you can’t assume that all blocking
operations will behave in quite the same way.
}
}

◊p{The ◊code-inline{factorial} task, on the other hand, did a lot of