[erlang-questions] Abusing OTP-8623 for high-priority messages

Ulf Wiger ulf@REDACTED
Fri Apr 11 12:52:38 CEST 2014


On 11 Apr 2014, at 11:04, Tony Rogvall <tony@REDACTED> wrote:

> This plan could almost work (theoretically), but would spam ManagerPid for every call to probe for 
> high prio message. And you surly add latency since you need to wait more than 0
> millis for a high prio response.
> 
> In other words, with my current mindset, the scheme is not really working.
> But with some new and fresh input this may inspire to even more abuse :-)

This is how to do it, of course:   ;-)

PrioRef = make_ref(),
ManagerPid ! {send_me_prio_request_with_this_ref, PrioRef},
erlang:hibernate(
    fun() ->
        receive
            {PrioRef, From, Msg} -> handle_call(From, Msg, State)
        after 0 ->
            receive
                Msg -> gen_server_like_dispatch_msg(Msg)
        end
    end).

Of course, hibernate/1 doesn’t exist, and the compiler would have
to make the fun ‘inherit’ the receive mark.

BR,
Ulf

Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc.
http://feuerlabs.com



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140411/0d491ec9/attachment.htm>


More information about the erlang-questions mailing list