[erlang-questions] monitor message queue of a process

Roberto Ostinelli roberto@REDACTED
Thu Apr 22 10:43:00 CEST 2010


2010/4/21 Kenneth Lundin <kenneth.lundin@REDACTED>:
> On Wed, Apr 21, 2010 at 9:10 PM, Zoltan Lajos Kis <kiszl@REDACTED> wrote:
>> Definitely not generic...
>> But as a quick hack you can set a trace flag on your process in order to
>> receive a message whenever the process receives one:
>> erlang:trace(Pid, true, ['receive', {tracer, MonitorPid}]).
>> This way you only need to check the queue length after the first n trace
>> messages, then after n-m messages, etc...
>
> Using the tracing mechanisms as part of the normal execution will
> destroy the possibilities to
> trace on the system without destroying the function. Therefore this is
> REALLY NOT RECOMMENDED.
>
> By the way , we will most likely optimize the selective receive for
> the result of  a gen_server call and similar until the next release
> (in the compiler and the Erlang VM).
>
> /Kenneth Erlang/OTP, Ericsson

thank you for the responses.

this leads me into thinking that the only possible solution is
therefore to have a message queuer buffer which must be actively
interrogated by the process when it is ready to receive new messages.

before i completely give up the idea of having some kind of automation
without compromising efficiency, are there any other ideas?

cheers,

r.


More information about the erlang-questions mailing list