Learn a powerful concurrency tool that makes complex coordination easy
Clojure is known for its powerful concurrency tools. It comes with a suite of primitives for managing shared mutable state. But how do you write code with multiple threads that communicate and coordinate with each other? In 2013, the Clojure team introduced core.async, an implementation of Communicating Sequential Processes for Clojure. It is a powerful, easily reasoned abstraction for writing highly concurrent code. It works in both Clojure and ClojureScript.
In this course, we go through the fundamentals with a real example. You'll learn:
- Why you want channels between your workers
- How to identify bottlenecks and eliminate them
- How to deal with deadlock
- A process for analyzing a network of workers
- Techniques for mastering time
- When and how to multitask
- How to break up tasks into smaller subtasks
Want this course?
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.
Overwhelmed by the number of functions in Clojure core.async? This reference sheet shows you just the essentials in an easy-to-follow format.
This lesson introduces you to Jennifer and Mark. Jennifer owns a toy factory and Mark builds toy cars. You'll begin to decompose a sequential process into the steps that will execute concurrently.
Hiring (Increasing Concurrency)
In this lesson, you get to work and start hiring more workers. You learn about go blocks, the powerful macro that enables core.async. You'll make several go blocks, see how they work, and start to make the process of building cars concurrent.
Assembly Line (Coordinating Between Processes)
In this lesson, things start getting serious. You've hired more workers, now they need to work together to build cars. And the common technique in factories is to use an assembly line. Learn to create patterns of communication between your processes using channels.
Conveyor Belts (Communicating using Channels)
Central to any modern factory are conveyor belts. In this lesson, you learn about buffers, which are like conveyor belts between go blocks.
Closing Shop (Stopping Processes)
This lesson addresses some issues that came up with the switch to conveyor belts. How do we tell everyone to stop working when the trucks are loaded and ready to ship? We don't want them to keep building cars. Learn about how to close channels so that they don't accept any more work.
Reducing Waste (Optimization)
In this lesson, the assembly line is shaping up. Now Jennifer is trying to make it more efficient. We begin looking at it at a high level and eliminating wasted work.
Deadlock (When No One Can Work)
In this lesson, we look at some problem areas where we could experience deadlock - our workers waiting forever. Looking at the problem in a picture makes it clear what we can do.
Consolidate (Scaling the right jobs)
In this lesson, we finally consolidate the work and improve scalability by analyzing the diagram of our assembly line.
Pomodoro (Incorporating Timers)
In this lesson, we turn our attention to management. Jennifer is trying out some productivity techniques in her office. Right now, she's implementing Pomodoro. We use core.async to sequence it.
Multitasking (Doing work while waiting for other work)
In this lesson, we learn how to do work while we are waiting for another go block to do other work. That means while we're waiting for a phone call, we can be planning our year. But if the phone rings, we stop what we're doing and answer it.