X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=Lucu.git;a=blobdiff_plain;f=Network%2FHTTP%2FLucu%2FResponseWriter.hs;h=be9f37088143ebc3e92eb73771b9dd3c1733df92;hp=a3a6af106071d6d8a5f7b357fab3ee4823e057ef;hb=47206637d664f163316dc9bb20983440ae4b138f;hpb=d05d8c883eaca12ee621975a2b95c5ebdc2357d2 diff --git a/Network/HTTP/Lucu/ResponseWriter.hs b/Network/HTTP/Lucu/ResponseWriter.hs index a3a6af1..be9f370 100644 --- a/Network/HTTP/Lucu/ResponseWriter.hs +++ b/Network/HTTP/Lucu/ResponseWriter.hs @@ -32,7 +32,8 @@ responseWriter cnf h tQueue readerTID where awaitSomethingToWrite :: IO () awaitSomethingToWrite - = do action + = {-# SCC "awaitSomethingToWrite" #-} + do action <- atomically $! do -- キューが空でなくなるまで待つ queue <- readTVar tQueue @@ -56,7 +57,8 @@ responseWriter cnf h tQueue readerTID writeContinueIfNecessary :: Interaction -> STM (IO ()) writeContinueIfNecessary itr - = itr `seq` + = {-# SCC "writeContinueIfNecessary" #-} + itr `seq` do expectedContinue <- readItr itr itrExpectedContinue id if expectedContinue then do wroteContinue <- readItr itr itrWroteContinue id @@ -78,11 +80,12 @@ responseWriter cnf h tQueue readerTID -- れば、ヘッダを出力する。ヘッダ出力後であり、bodyToSend が -- 空でなければ、それを出力する。空である時は、もし状態が -- Done であれば後処理をする。 - = itr `seq` + = {-# SCC "writeHeaderOrBodyIfNecessary" #-} + itr `seq` do wroteHeader <- readItr itr itrWroteHeader id if not wroteHeader then - return $ writeHeader itr + return $! writeHeader itr else do bodyToSend <- readItr itr itrBodyToSend id @@ -98,7 +101,8 @@ responseWriter cnf h tQueue readerTID writeContinue :: Interaction -> IO () writeContinue itr - = itr `seq` + = {-# SCC "writeContinue" #-} + itr `seq` do let cont = Response { resVersion = HttpVersion 1 1 , resStatus = Continue @@ -112,7 +116,8 @@ responseWriter cnf h tQueue readerTID writeHeader :: Interaction -> IO () writeHeader itr - = itr `seq` + = {-# SCC "writeHeader" #-} + itr `seq` do res <- atomically $! do writeItr itr itrWroteHeader True readItr itr itrResponse id hPutResponse h res @@ -121,7 +126,8 @@ responseWriter cnf h tQueue readerTID writeBodyChunk :: Interaction -> IO () writeBodyChunk itr - = itr `seq` + = {-# SCC "writeBodyChunk" #-} + itr `seq` do willDiscardBody <- atomically $! readItr itr itrWillDiscardBody id willChunkBody <- atomically $! readItr itr itrWillChunkBody id chunk <- atomically $! do chunk <- readItr itr itrBodyToSend id @@ -140,7 +146,8 @@ responseWriter cnf h tQueue readerTID finishBodyChunk :: Interaction -> IO () finishBodyChunk itr - = itr `seq` + = {-# SCC "finishBodyChunk" #-} + itr `seq` do willDiscardBody <- atomically $! readItr itr itrWillDiscardBody id willChunkBody <- atomically $! readItr itr itrWillChunkBody id when (not willDiscardBody && willChunkBody) @@ -148,7 +155,8 @@ responseWriter cnf h tQueue readerTID finalize :: Interaction -> IO () finalize itr - = itr `seq` + = {-# SCC "finalize" #-} + itr `seq` do finishBodyChunk itr willClose <- atomically $! do queue <- readTVar tQueue