id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	os	architecture	failure	difficulty	testcase	blockedby	blocking	related
7216	Compositional blocking on file descriptors	AndreasVoellmy	igloo	"The GHC.Event.Thread module provides threadWaitRead, threadWaitWrite :: Fd -> IO () calls that block until a particular file descriptor is ready for reading or writing. With this API a single thread cannot wait on multiple file descriptors or a file descriptor and some other condition (e.g. an MVar, STM transaction, etc). One could work around this by creating extra producer threads that each monitor one file descriptor and then multiplex messages from those threads onto a single channel (or mvar, etc) and then have a consumer thread that waits on this single multiplexed channel. Unfortunately, this extra indirection imposes a modest performance penalty in the form of longer wait times to service events due to having to switch between multiple threads to handle a single ready file. 

I propose to provide analogous functions in the STM monad threadWaitReadSTM,threadWaitWriteSTM :: Fd -> STM (). These will allow a single thread to wait on multiple files or both files and other conditions. This eliminates the switching between threads to service a request. "	feature request	closed	normal	7.8.1	libraries/base	7.4.2	fixed			Unknown/Multiple	Unknown/Multiple	None/Unknown	Unknown				
