[erlang-questions] Manually remove a message from Process Mailbox

Tony Rogvall tony@REDACTED
Fri Jan 4 20:51:12 CET 2013


Hi! 
And happy new year.

If you also simulate send you could send with a unique reference:
Replace
	Pid !  Message
With
	Pid ! {make_ref(), Message}

Then you can get the k'th message {Ref,Message} and do a selective receive to remove that message:

	receive
		{Ref,_Message} -> ok
	end

A bit on the heavy side, but fun.  
Handling timeout is a bit more tricky, but solvable with the above schema.

/Tony

On 4 jan 2013, at 20:22, Aggelos Giantsios <aggelgian@REDACTED> wrote:

> Happy New Year to everyone!
> 
> I am trying to simulate the 'receive' expression behaviour.
> I access the process message queue with erlang:process_info(self(), messages).
> Assuming I have selected a message Msg which is at position k in the message list and have safely stored it in a variable,
> is there a way to manually remove Msg from the process message queue?
> 
> Thanks,
> Aggelos
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

"Installing applications can lead to corruption over time. Applications gradually write over each other's libraries, partial upgrades occur, user and system errors happen, and minute changes may be unnoticeable and difficult to fix"



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


More information about the erlang-questions mailing list