It depends on the nature of your multi-threaded philosophy. For those of us who prefer Conversational Process Communication, the blocking queue is almost perfect. In fact, the ideal one would be where the message cannot be queued at all if the receiver is not ready to receive it.
No, I don’t think that the blocking queue runs counter to the very goal of multithreading. In fact, the scenario you are describing (the main thread is ultimately stalled) is a good illustration of a serious problem with the actor-model of multithreading; you do not know if it will be blocked / blocked, and you also cannot exhaustively check it.
In contrast, imagine a blocking queue with zero messages. Thus, for the system to work in general, you had to find a way to ensure that the log is always guaranteed to be able to receive a message from the main stream. This is a CSP. This may mean that in your hypothetical log stream you should have the application-defined buffering (as opposed to which framework designer best guesses how deep the FIFO should be), the fast I / O subsystem checks to see if , lag, etc. In short, this does not allow you to get away from it, you are forced to solve all aspects of the performance of your system.
This, of course, is more complicated, but in this way you get a system that is definitely OK, and not the dubious “maybe” that you have if your blocking queues are an unknown number of messages.
bazza source share