Couldn't this part of this article (image below)
be done with a semaphore much easier? I get that channels can help when your application gets bigger, but i'm wondering if channels are a bit much for this problem.
With a semaphore implementation the methods would still suspend until one of the workers could be freed up
I don't see how a semaphore is any better, select also suspends until one of the workers frees up if used correctly
11/07/2019, 5:33 PM
@Casey Brooks thats what i'm talking about. the coroutines semaphore.
@octylFractal so if semaphores aren't any better (which is totally valid, im trying to understand), can you explain how a channel is better for this purpose?
11/07/2019, 5:34 PM
because it also allows data flow between the coroutines? a semaphore can't do that without additional objects, adding to the complexity of that code. any further and you're basically rebuilding channels
11/07/2019, 5:35 PM
A channel is an abstraction over communication between coroutines. They help you not need to think about concurrency primitives, and instead just focus on sending/receiving data. Normal thread synchronization techniques are notoriously error-prone because these primitives are difficult to use correctly, and channels help you avoid using those primitives while still having safe, concurrent code