[erlang-questions] monitor message queue of a process

Kenneth Lundin kenneth.lundin@REDACTED
Wed Apr 21 22:40:52 CEST 2010


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

> Regards,
> Zoltan.
>
>
>
> On 4/21/2010 7:26 PM, Roberto Ostinelli wrote:
>>
>> dear list,
>>
>> i would like to know if there's a native way to monitor and react on a
>> message queue of a process, without the need to modify the process
>> itself.
>>
>> it's quite easy to get the message queue length using
>> erlang:process_info/2, however i would need this monitoring done not
>> in a polling-way [which would periodically check for this
>> information], but i would love to have some kind of a message when the
>> queue length is modified and satisfies some requisites.
>>
>> i'm trying to figure out a way to provide some kind of generic
>> buffering technique to solve selective receives' snowball effect that
>> is being discussed so much lately.
>>
>> ideas welcome.
>>
>> r.
>>
>> ________________________________________________________________
>> erlang-questions (at) erlang.org mailing list.
>> See http://www.erlang.org/faq.html
>> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
>>
>>
>
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
>
>


More information about the erlang-questions mailing list