import Control.Concurrent
import Control.Concurrent.STM
import Control.Exception
-import Control.Monad.Reader
+import Control.Monad
import Data.Dynamic
import Data.List
import qualified Data.Map as M
-- | 'ResourceDef' is basically a set of
-- 'Network.HTTP.Lucu.Resource.Resource' monads for each HTTP methods.
data ResourceDef = ResourceDef {
- -- | Whether to run a 'Network.HTTP.Lucu.Resource.Resource' on a
- -- native thread (spawned using @forkOS@) or to run it on a user
- -- thread (spanwed using @forkIO@). Generally you don't
+ -- |Whether to run a 'Network.HTTP.Lucu.Resource.Resource' on a
+ -- native thread (spawned by 'Control.Concurrent.forkOS') or to
+ -- run it on a user thread (spanwed by
+ -- 'Control.Concurrent.forkIO'). Generally you don't need to set
+ -- this field to 'Prelude.True'.
resUsesNativeThread :: !Bool
-- | Whether to be greedy or not.
--
runResource def itr
= def `seq` itr `seq`
fork
- $! catch ( runReaderT ( do req <- getRequest
- fromMaybe notAllowed $ rsrc req
- driftTo Done
- ) itr
+ $! catch ( runRes ( do req <- getRequest
+ fromMaybe notAllowed $ rsrc req
+ driftTo Done
+ ) itr
)
$ \ exc -> processException exc
where
reqM <- atomically $ readItr itr itrRequest id
res <- atomically $ readItr itr itrResponse id
if state <= DecidingHeader then
- flip runReaderT itr
+ flip runRes itr
$ do setStatus $ aboStatus abo
-- FIXME: 同じ名前で複數の値があった時は、こ
-- れではまずいと思ふ。
when (cnfDumpTooLateAbortionToStderr $ itrConfig itr)
$ hPutStrLn stderr $ show abo
- flip runReaderT itr $ driftTo Done
+ flip runRes itr $ driftTo Done
formatIOE :: IOError -> String
formatIOE ioE = if isUserError ioE then