use async to track and manage threads
This commit is contained in:
parent
7fc6ebb765
commit
1713ed95f7
11 changed files with 77 additions and 61 deletions
16
Assistant.hs
16
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue