summaryrefslogtreecommitdiff
path: root/Utility
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-07-28 21:11:40 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-07-28 21:11:40 -0400
commit5be5cb219f1d277fbc7c8b0a33a9012fcd219a00 (patch)
tree660a32537f82c0fd069ce60114d4b505b5fedf36 /Utility
parent109dc122da2c2fb1efdb83e5e361fe95fc4f1b16 (diff)
add derives needed for use with Yesod, and fix a bug
Diffstat (limited to 'Utility')
-rw-r--r--Utility/NotificationBroadcaster.hs6
1 files changed, 4 insertions, 2 deletions
diff --git a/Utility/NotificationBroadcaster.hs b/Utility/NotificationBroadcaster.hs
index 1b05329e2..c811152ff 100644
--- a/Utility/NotificationBroadcaster.hs
+++ b/Utility/NotificationBroadcaster.hs
@@ -14,6 +14,7 @@
module Utility.NotificationBroadcaster (
NotificationBroadcaster,
NotificationHandle,
+ NotificationId,
newNotificationBroadcaster,
newNotificationHandle,
notificationHandleToId,
@@ -31,6 +32,7 @@ import Control.Concurrent.SampleVar
type NotificationBroadcaster = TMVar [SampleVar ()]
newtype NotificationId = NotificationId Int
+ deriving (Read, Eq, Ord)
instance Show NotificationId where
show (NotificationId i) = show i
@@ -39,7 +41,7 @@ instance Show NotificationId where
data NotificationHandle = NotificationHandle NotificationBroadcaster NotificationId
newNotificationBroadcaster :: IO NotificationBroadcaster
-newNotificationBroadcaster = atomically (newTMVar [])
+newNotificationBroadcaster = atomically $ newTMVar []
{- Allocates a notification handle for a client to use. -}
newNotificationHandle :: NotificationBroadcaster -> IO NotificationHandle
@@ -50,7 +52,7 @@ newNotificationHandle b = NotificationHandle
addclient = do
s <- newEmptySampleVar
atomically $ do
- l <- readTMVar b
+ l <- takeTMVar b
putTMVar b $ l ++ [s]
return $ NotificationId $ length l