• Skip to main content
  • Skip to footer

PurelyFunctional.tv

  • Learn Clojure
  • About
  • 🛒 Cart
  • Log in

Master Clojure concurrency

You've heard that Clojure is great for concurrency. But what tools does Clojure give you? And how should you use those tools? There are a lot of tools available, and each has its strengths and weaknesses. It can be difficult to learn how to choose between them. But once you do, you'll be firing up threads left and right to get work done in parallel.

These lessons are meant to each answer a specific question and help you build the skills you need to address a wide variety of concurrency problems.

Concurrency

Updated May 26, 2019

Want this course?

Team License

$200
Get this course
HD Download
Watch Online
Lifetime Access
For your company
$200.00 – ADD TO CART Checkout Added to cart

Download License

$24
Get this course
HD Download
Watch Online
Lifetime Access
For an individual
$24.00 – ADD TO CART Checkout Added to cart

Online License

$18
Get this course
--
Watch Online
Lifetime Access
For an individual
$18.00 – ADD TO CART Checkout Added to cart

Membership

$49/mo
Get all courses
HD Download
Watch Online
Monthly/Yearly access
For an individual
$49/mo - GET ACCESS

Love it or leave it guarantee

If you don't learn as much from this course as you thought, just ask for a refund within 30 days and I'll give you your money back.

Video time: 03h14m
0 / 15
0 / 15

Lessons

12 min

1. Delay

Sometimes you have a shared bit of code that you only want run once, even if you want to share the result of the code. How is that like a coffee pot? Well, we'll see!

10 min

2. Promise

Sometimes we want to use another Thread to do some work, but we need the result of that work back in the main Thread. We can have the worker thread promise to put the value in a Promise. We can deref the Promise and get it out or block.

3 min

3. Future

Sometimes you want to perform a calculation in another Thread and capture it in something like a Promise in one go. That's what Future is for.

8 min

4. Deref

deref is an important function because it is used so much in Clojure. It's used to get the current value out of the reference types in Clojure, including Atoms, Refs, Vars, Futures, Promises, and Delays. There are some things you need to know about it.

10 min

5. Keeping state consistent with Atoms

If we share mutable state between threads, the values can become inconsistent. Clojure uses Atoms to ensure that a mutable value is always consistent, even when written to by multiple threads.

9 min

6. Sharing state among many threads: Atoms

How do you use atoms to help many threads share state? The video is 10 minutes long.

27 min

7. Ref

Whenever you need to keep two or more values in a consistent relationship, Refs are available. They give you transactional properties across multiple Refs. We look at the example of calculating an average and keeping a Farenheit value consistent with a Celsius reading.

30 min

8. Vars

You'll typically use Vars in three use cases. 1) Dynamic development 2) Dynamic scope 3) testing. Most of the time, you won't even know you're using them because they're baked into the language.

23 min

9. Agents

Agents are another reference type. Each one has a queue of work to be run on it, and those bits of work get run in a thread pool. They're great because each Agent is a unit of parallelization. Three Agents mean three things can run at the same time.

9 min

10. Locking

Locking is a low-level mechanism for making sure only one Thread runs some code at the same time. It's like a lock on your bathroom. It keeps others out so you can do what you need to do in peace.

9 min

11. Core Async

Core Async is a library for concurrency brought to us by the core Clojure team. I love it because it's a game changer for complex concurrent tasks. It's very versatile and can be used to implement many common patterns.

8 min

12. Threads

The basic unit of parallelization in the JVM is the Thread. Java provides a mechanism for creating and starting native Threads. We go over how to use them.

10 min

13. ExecutorService

Java provides a library called ExecutorService. It's a thread pool fed by a queue. You send it tasks (functions) and you get back Futures with your answers.

15 min

14. ForkJoin

Fork/Join is a library that comes with Java for doing highly parallel computations. It lets you recursively break up work, do the work, and put the pieces back together.

8 min

15. Reducers

Reducers is a library that comes with Clojure. It's a wrapper around Fork/Join, so it gives you highly parallel implementations of regular functional tools like map, filter, and reduce.

Footer CTA

Get the newsletter for free

The PurelyFunctional.tv Newsletter is a weekly email to inspire functional programmers.

Enter your email address to receive emails about Clojure and Functional Programming. These include the weekly newsletter and other great offers. You can unsubscribe any time.

Copyright © 2021 LispCast and Eric Normand