netserver/Miscutils.hs
changeset 889 3bf9dc791f45
parent 852 f756a1d3324c
child 890 1d8c4a5ec622
--- a/netserver/Miscutils.hs	Sun Apr 27 16:51:28 2008 +0000
+++ b/netserver/Miscutils.hs	Wed Apr 30 16:50:28 2008 +0000
@@ -9,6 +9,7 @@
 data ClientInfo =
 	ClientInfo
 	{
+		chan :: TChan String,
 		handle :: Handle,
 		nick :: String,
 		room :: String,
@@ -51,4 +52,7 @@
 			writeTVar state1 ol1
 			writeTVar state2 ol2
 			return res
-	
+
+tselect :: [ClientInfo] -> STM (String, Handle)
+tselect = foldl orElse retry . map (\ci -> (flip (,) (handle ci)) `fmap` readTChan (chan ci))
+