diff options
author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2012-08-22 22:37:33 +0200 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2012-08-22 22:37:33 +0200 |
commit | 8e87d8671c06eb5acca3a4c92e569e1dba253160 (patch) | |
tree | 30a68352ed847b7d19c7951b0c8c76187838753f /src/Signal.hs | |
parent | 2596e2a21d23979ca1bebd87698b00e195d5b5d9 (diff) | |
parent | 68f9f51cd7e20190e1ef2fd95beaf7c852f11c81 (diff) | |
download | xmobar-8e87d8671c06eb5acca3a4c92e569e1dba253160.tar.gz xmobar-8e87d8671c06eb5acca3a4c92e569e1dba253160.tar.bz2 |
Merge remote-tracking branch 'jrk/replacemvar' into jrk
Conflicts:
readme.md
Diffstat (limited to 'src/Signal.hs')
-rw-r--r-- | src/Signal.hs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/Signal.hs b/src/Signal.hs index a003859..44fe4f9 100644 --- a/src/Signal.hs +++ b/src/Signal.hs @@ -19,7 +19,7 @@ module Signal where import Data.Typeable (Typeable) -import Control.Concurrent +import Control.Concurrent.STM import Control.Exception hiding (handle) import System.Posix.Signals @@ -52,19 +52,19 @@ parseSignalType :: String -> Maybe SignalType parseSignalType = fmap fst . safeHead . reads -- | Signal handling -setupSignalHandler :: IO (MVar SignalType) +setupSignalHandler :: IO (TMVar SignalType) setupSignalHandler = do - tid <- newEmptyMVar + tid <- newEmptyTMVarIO installHandler sigUSR2 (Catch $ updatePosHandler tid) Nothing installHandler sigUSR1 (Catch $ changeScreenHandler tid) Nothing return tid -updatePosHandler :: MVar SignalType -> IO () +updatePosHandler :: TMVar SignalType -> IO () updatePosHandler sig = do - putMVar sig Reposition + atomically $ putTMVar sig Reposition return () -changeScreenHandler :: MVar SignalType -> IO () +changeScreenHandler :: TMVar SignalType -> IO () changeScreenHandler sig = do - putMVar sig ChangeScreen + atomically $ putTMVar sig ChangeScreen return () |