summaryrefslogtreecommitdiff
path: root/Assistant/Types
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-01-26 17:09:33 +1100
committerGravatar Joey Hess <joey@kitenet.net>2013-01-26 17:09:33 +1100
commitdc60216eb8fe919acf7ab3984a5f0bf0e0193f6b (patch)
tree7fb8c8bd0189f1868e732fc1c6047df933333ecf /Assistant/Types
parentf0f97334d017eac6d1693bac90c772022fa57aa7 (diff)
webapp: Now allows restarting any threads that crash.
Diffstat (limited to 'Assistant/Types')
-rw-r--r--Assistant/Types/DaemonStatus.hs6
-rw-r--r--Assistant/Types/NamedThread.hs17
-rw-r--r--Assistant/Types/ThreadName.hs14
3 files changed, 35 insertions, 2 deletions
diff --git a/Assistant/Types/DaemonStatus.hs b/Assistant/Types/DaemonStatus.hs
index 6c949c8f4..b60d49edf 100644
--- a/Assistant/Types/DaemonStatus.hs
+++ b/Assistant/Types/DaemonStatus.hs
@@ -14,6 +14,7 @@ import Assistant.Alert
import Assistant.Pairing
import Utility.NotificationBroadcaster
import Logs.Transfer
+import Assistant.Types.ThreadName
import Control.Concurrent.STM
import Control.Concurrent.Async
@@ -21,8 +22,9 @@ import Data.Time.Clock.POSIX
import qualified Data.Map as M
data DaemonStatus = DaemonStatus
- -- All the named threads that comprise the daemon.
- { startedThreads :: M.Map String (Async ())
+ -- All the named threads that comprise the daemon,
+ -- and actions to run to restart them.
+ { startedThreads :: M.Map ThreadName (Async (), IO ())
-- False when the daemon is performing its startup scan
, scanComplete :: Bool
-- Time when a previous process of the daemon was running ok
diff --git a/Assistant/Types/NamedThread.hs b/Assistant/Types/NamedThread.hs
new file mode 100644
index 000000000..0e884637a
--- /dev/null
+++ b/Assistant/Types/NamedThread.hs
@@ -0,0 +1,17 @@
+{- named threads
+ -
+ - Copyright 2012 Joey Hess <joey@kitenet.net>
+ -
+ - Licensed under the GNU GPL version 3 or higher.
+ -}
+
+module Assistant.Types.NamedThread where
+
+import Assistant.Monad
+import Assistant.Types.ThreadName
+
+{- Information about a named thread that can be run. -}
+data NamedThread = NamedThread ThreadName (Assistant ())
+
+namedThread :: String -> Assistant () -> NamedThread
+namedThread name a = NamedThread (ThreadName name) a
diff --git a/Assistant/Types/ThreadName.hs b/Assistant/Types/ThreadName.hs
new file mode 100644
index 000000000..c8d264a38
--- /dev/null
+++ b/Assistant/Types/ThreadName.hs
@@ -0,0 +1,14 @@
+{- name of a thread
+ -
+ - Copyright 2012 Joey Hess <joey@kitenet.net>
+ -
+ - Licensed under the GNU GPL version 3 or higher.
+ -}
+
+module Assistant.Types.ThreadName where
+
+newtype ThreadName = ThreadName String
+ deriving (Eq, Read, Show, Ord)
+
+fromThreadName :: ThreadName -> String
+fromThreadName (ThreadName n) = n