diff options
author | Joey Hess <joey@kitenet.net> | 2013-01-26 14:14:32 +1100 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-01-26 14:14:32 +1100 |
commit | 44d7913686ccfef4e6cbd0fdc2b5611aa944ec70 (patch) | |
tree | b8343b59f6730ff31fb7b88ffc11e13073d88c8e /Assistant.hs | |
parent | 28eb1f598b1f494b6de815593fa8bfb9aaaeb250 (diff) |
use async to track and manage threads
Diffstat (limited to 'Assistant.hs')
-rw-r--r-- | Assistant.hs | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/Assistant.hs b/Assistant.hs index 06f8d64e5..d1a9f7102 100644 --- a/Assistant.hs +++ b/Assistant.hs @@ -154,11 +154,6 @@ import Assistant.Threads.XMPPClient import Assistant.Environment import qualified Utility.Daemon import Utility.LogFile -import Utility.ThreadScheduler - -import Control.Concurrent - -type NamedThread = IO () -> IO (String, IO ()) stopDaemon :: Annex () stopDaemon = liftIO . Utility.Daemon.stopDaemon =<< fromRepo gitAnnexPidFile @@ -197,11 +192,11 @@ startDaemon assistant foreground startbrowser = do =<< newAssistantData st dstatus go webappwaiter = do - d <- getAssistant id #ifdef WITH_WEBAPP + d <- getAssistant id urlrenderer <- liftIO newUrlRenderer #endif - mapM_ (startthread d) + mapM_ startthread [ watch $ commitThread #ifdef WITH_WEBAPP , assist $ webAppThread d urlrenderer False Nothing webappwaiter @@ -229,11 +224,10 @@ startDaemon assistant foreground startbrowser = do , watch $ watchThread ] - liftIO waitForTermination + waitNamedThreads watch a = (True, a) assist a = (False, a) - startthread d (watcher, t) - | watcher || assistant = void $ liftIO $ forkIO $ - runAssistant d $ runNamedThread t + startthread (watcher, t) + | watcher || assistant = startNamedThread t | otherwise = noop |