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.
Parts of courses on specific topics
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.
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.
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.
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.
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.