[GHC] #7216: Compositional blocking on file descriptors
GHC
cvs-ghc at haskell.org
Tue Sep 4 06:03:53 CEST 2012
#7216: Compositional blocking on file descriptors
------------------------------+---------------------------------------------
Reporter: AndreasVoellmy | Owner:
Type: feature request | Status: new
Priority: normal | Component: libraries/base
Version: 7.4.2 | Keywords:
Os: Unknown/Multiple | Architecture: Unknown/Multiple
Failure: None/Unknown | Testcase:
Blockedby: | Blocking:
Related: |
------------------------------+---------------------------------------------
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.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7216>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list