3 ms·
Yes, sending closures over channels is a very convenient and flexible concurrency framework. In fact it would be handy for all channels to have a standard handl
by iainmerrick 8y ago
Yes, sending closures over channels is a very convenient and flexible concurrency framework. In fact it would be handy for all channels to have a standard handler attached, that pulls closures from the channel and executes them. Among other benefits that would mean you didn’t need a separate “go” keyword; to execute a function in the background you just post it to a channel. That’s basically how Java thread pools and Grand Central Dispatch work.
The idiom of defining message types that you post to a channel so that you can pull them from the channel and execute them strikes me as boilerplate. What you really want to do is run some code in a particular thread context; so why not just do that directly?
Are there useful things you do with channels that can’t easily be done with thread pools?