aboutsummaryrefslogtreecommitdiff
path: root/server/src
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2016-02-14 21:41:53 +0000
committerGregor Kleen <gkleen@yggdrasil.li>2016-02-14 21:41:53 +0000
commit575a06949d7271734db4d52fe512981d6c0e139d (patch)
treed05f9e7d4a5089fede05ea3e1b490482b91c8e61 /server/src
parentf4aa09d615a9cb77f1d13cbbc516be23a2d3cc69 (diff)
downloadthermoprint-575a06949d7271734db4d52fe512981d6c0e139d.tar
thermoprint-575a06949d7271734db4d52fe512981d6c0e139d.tar.gz
thermoprint-575a06949d7271734db4d52fe512981d6c0e139d.tar.bz2
thermoprint-575a06949d7271734db4d52fe512981d6c0e139d.tar.xz
thermoprint-575a06949d7271734db4d52fe512981d6c0e139d.zip
Support for exception masking in PrinterMethods
Diffstat (limited to 'server/src')
-rw-r--r--server/src/Thermoprint/Server.hs2
-rw-r--r--server/src/Thermoprint/Server/Printer.hs4
2 files changed, 5 insertions, 1 deletions
diff --git a/server/src/Thermoprint/Server.hs b/server/src/Thermoprint/Server.hs
index 2413b2a..678d056 100644
--- a/server/src/Thermoprint/Server.hs
+++ b/server/src/Thermoprint/Server.hs
@@ -34,6 +34,7 @@ import Control.Monad.Reader
34import Control.Monad.IO.Class 34import Control.Monad.IO.Class
35import Control.Monad.Morph 35import Control.Monad.Morph
36import Control.Category 36import Control.Category
37import Control.Monad.Catch (MonadMask)
37import Prelude hiding (id, (.)) 38import Prelude hiding (id, (.))
38 39
39import qualified Control.Monad as M 40import qualified Control.Monad as M
@@ -105,6 +106,7 @@ withPrinters cfg = fmap updateCfg . foldlM mapInsert (Map.mapWithKey (\k a -> (a
105thermoprintServer :: ( MonadLoggerIO m 106thermoprintServer :: ( MonadLoggerIO m
106 , MonadReader ConnectionPool m 107 , MonadReader ConnectionPool m
107 , MonadResourceBase m 108 , MonadResourceBase m
109 , MonadMask m
108 ) => (m :~> IO) -- ^ 'dyre' controls the base of the monad-transformer-stack ('IO') but we let the user specify much of the rest of it (we handle 'ResourceT' ourselves, since we need it to fork properly). Therefore we require a specification of how to collapse the stack. 110 ) => (m :~> IO) -- ^ 'dyre' controls the base of the monad-transformer-stack ('IO') but we let the user specify much of the rest of it (we handle 'ResourceT' ourselves, since we need it to fork properly). Therefore we require a specification of how to collapse the stack.
109 -> ResourceT m (Config (ResourceT m)) -> IO () 111 -> ResourceT m (Config (ResourceT m)) -> IO ()
110-- ^ Run the server 112-- ^ Run the server
diff --git a/server/src/Thermoprint/Server/Printer.hs b/server/src/Thermoprint/Server/Printer.hs
index d9cea9d..d0dc37b 100644
--- a/server/src/Thermoprint/Server/Printer.hs
+++ b/server/src/Thermoprint/Server/Printer.hs
@@ -40,6 +40,7 @@ import Control.Monad.Trans.Resource
40import Control.Monad.IO.Class 40import Control.Monad.IO.Class
41import Control.Monad.Logger 41import Control.Monad.Logger
42import Control.Monad.Reader 42import Control.Monad.Reader
43import Control.Monad.Catch (MonadMask)
43 44
44import Control.Monad (forever) 45import Control.Monad (forever)
45 46
@@ -49,7 +50,7 @@ import Data.Time.Clock
49 50
50import Thermoprint.Server.Queue 51import Thermoprint.Server.Queue
51 52
52newtype PrinterMethod = PM { unPM :: forall m. (MonadResource m, MonadLogger m) => Printout -> m (Maybe PrintingError) } 53newtype PrinterMethod = PM { unPM :: forall m. (MonadResource m, MonadLogger m, MonadMask m) => Printout -> m (Maybe PrintingError) }
53 54
54data Printer = Printer 55data Printer = Printer
55 { print :: PrinterMethod 56 { print :: PrinterMethod
@@ -69,6 +70,7 @@ runPrinter :: ( MonadReader ConnectionPool m
69 , MonadLogger m 70 , MonadLogger m
70 , MonadBaseControl IO m 71 , MonadBaseControl IO m
71 , MonadResource m 72 , MonadResource m
73 , MonadMask m
72 ) => Printer -> m () 74 ) => Printer -> m ()
73-- ^ Loop 'forever' pushing entries from the 'Queue' associated to a 'Printer' into its 'print'-method 75-- ^ Loop 'forever' pushing entries from the 'Queue' associated to a 'Printer' into its 'print'-method
74runPrinter Printer{..} = forever $ do 76runPrinter Printer{..} = forever $ do