gen_server and priority queues

Richard Cameron <>
Mon Oct 24 17:38:11 CEST 2005

I want to implement a server which processes messages in order of  
priority. I know I can do this in pure Erlang as:

handle(high, State) ->
     receive {high,Msg} ->
     after 0 ->
             handle(medium, State)
handle(medium, State) ->
     receive {medium,Msg} ->
             do(Msg, State)
     after 0 ->
             handle(low, State)
handle(low, State) ->
     receive {_,Msg} ->
             do(Msg, State)

... but what I really want is to be able to do this within OTP's  
gen_server behaviour. Is there a nice way to do this, or do I just  
need to roll my own server and then attach it to my supervision tree  
with a bridge?


More information about the erlang-questions mailing list