[erlang-questions] On selective receive (Re: eep: multiple patterns)

Anthony Shipman als@REDACTED
Wed Jun 4 16:48:41 CEST 2008


On Wed, 4 Jun 2008 11:27:02 pm Vlad Dumitrescu wrote:
> On Wed, Jun 4, 2008 at 2:51 PM, Andreas Hillqvist <

>
> I think that conceptually, multiple queues would be just like wrapping all
> messages with {QueueId, Message} and use selective receive to discriminate,
> only faster. Especially if one queue is low priority and high volume.
>
> I think that it is enough with only one extra queue, for system messages.
> With it, it's very easy to implement any number of queues with the help of
> assisting processes. The system queue would be used to send receive
> requests to the helper process without these requests getting in a possibly
> large queue of normal messages.

First-class queues are used in Concurrent ML to good effect. If a process 
wants to make an RPC it creates a queue for the response and passes a handle 
to it in the call. The remote procedure sends its response through the queue.  
The caller blocks on pulling the response from the queue. 

The equivalent in Erlang is to shove all messages into the one process queue 
and use a reference to pull out the response. This can lead to the slow queue 
searching that everyone is talking about.

Changing the paradigm now though would make the language rather messy.
-- 
Anthony Shipman                    Mamas don't let your babies 
als@REDACTED                   grow up to be outsourced.



More information about the erlang-questions mailing list