2 ms·
I have no experience with either Go or Erlang but if you have blocking reads, it doesn't seem too complicated to get an efficient blocking write to a multiplexe
by drostie 11y ago
I have no experience with either Go or Erlang but if you have blocking reads, it doesn't seem too complicated to get an efficient blocking write to a multiplexed channel.
I guess I should be a little more clear on my assumptions going into this, chiefly that "you can send enough information to get a worker to non-blocking-send an acknowledgement back to you telling you that they accepted the workload." If you can't do that then I'm not sure what would happen, and that seems like a legitimate language problem. Call this ACK-mechanism a "private channel", say.
A blocking write consists of opening a private channel, issuing a write to the multiplexed channel that contains some sort of "address" for your private channel, and then issuing a blocking read on the private channel. To do this, workers need to be designed so that the first thing they do when they pick up a work order involves sending the ACK containing the ID from the work order and the ID of the worker. Then, when there aren't enough workers to pick up your request immediately, you get to block on your private read until someone picks up your workload and messages you, "hey, I'm just getting around to this...".