Tuesday, November 11, 2008

Erlang queues — a worked example

Mainly to put down where I can find it again (Google not having turned up any reassuring examples, particularly for queue:split()) that they do act as you think they would:

So queue:in() puts new entries into the queue, queue:split() counts from the output end, breaking the output as {Old, New}, queue:head() peeks and queue:out() pops.

In particular {_, NewQ} = queue:split(Discard, Q). will drop the indicated number of expired entries from the queue.

Post a Comment