[Haskell-cafe] Implementing tryReadMVar

MR K P SCHUPKE k.schupke at imperial.ac.uk
Wed Sep 1 13:30:17 EDT 2004


>might be a reason to want to prefer one event over another.

You can still use a single channel... If you read all pending events on the
channel into a FIFO (lazy list) then you can check for high priority events
on read, and then deal with the next item on the top of the FIFO... something
like the following (in pseudo code)

	while channel not empty
		read next event
		if event high priority process now
		else queue event in FIFO
	process first event in FIFO

So inbetween processing low priority events we check ahead for any high
priority ones...

This could be extended with multiple FIFO's to deal with multiple priority
levels... but this ensures all events are dealt with sequentially (if out
of order)#

	Keean.


More information about the Haskell-Cafe mailing list