Clojure core.async provides basic building blocks for communication and coordination. This course explores ten patterns you can easily implement using those building blocks. I really like how little code it takes to build powerful concurrency patterns.

Want this course?

Team License

  • HD Download
  • Watch Online
  • Lifetime Access
  • For your company

Download License

  • HD Download
  • Watch Online
  • Lifetime Access
  • For an individual

Online License

  • Watch Online
  • Lifetime Access
  • For an individual


  • HD Downloads
  • Watch Online
  • Full access
  • All Content
  • For an individual
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.

core.async Patterns


Video time: 50m02s

0 / 10

Take with Timeout
  • 6 min

What if you want to take from a channel, but give up after a time? This is very useful when testing that something was put onto a channel. You can't wait forever, because then your tests will never finish. core.async makes this quite easy.

Put with Timeout
  • 1 min

We saw how to take with a timeout. But how do you put with a timeout? If a channel is full, a put will block or park until it is empty. If that never happens, your code will never complete. core.async can do this as well.

  • 7 min

I often have trouble figuring out when my go blocks fail and why. Exceptions are silently ignored. We can write a macro that captures the exception and passes it back out of the go block to the code where it is used.

Thread pool
  • 5 min

When work tasks are being produced, we often want to handle them in a thread pool. This is exceedingly easy in core.async. Channels are queues, and we can use the core.async/thread macro to create threads easily. If each loops through the tasks it gets from the queue, the work can be done in parallel.

  • 8 min

Backpressure is incredibly important in a distrubuted environment. Our servers can face more load than they can handle. Web requests are cheaper to produce than to respond to. The best practice when faced with more requests than you can handle is to immediately respond that you can't handle it so that you can continue processing the requests you've already accepted.

Kill switch
  • 3 min

On the JVM, there is no way to stop a thread from the outside. The same is true of core.async go processes. The only way to stop it is from the inside. A common way to kill multiple threads/go processes is to make a channel signal that they should die.

Poison pill
  • 4 min

If you need finer control over which workers die, you could implement the poison pill pattern. In this one, a special value is considered to be a signal to die.

Start latch
  • 2 min

When you need many go blocks to start work at very close to the same time, you can use a start latch. This pattern preps go blocks and signals them to start with the same channel.

Token bucket
  • 6 min

Rate limiting is kind of hard to implement, especially across multiple threads. But in core.async, it's not hard at all. In this lesson, we implement a simple rate limiting algorithm called a token bucket.

Refining values over time
  • 8 min

core.async lets us do things to play with time that we otherwise would have a lot of trouble with. One thing we might want is to request a value that is always current.