-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add cleanup to folds #904
Add cleanup to folds #904
Conversation
Regression report attached |
@@ -378,6 +378,13 @@ lpackArraysChunksOf n (Fold step1 initial1 extract1) = | |||
FL.Partial rr -> extract1 rr | |||
FL.Done () -> return () | |||
|
|||
clean (Tuple' Nothing r1) = clean1 r1 | |||
clean (Tuple' (Just buf) r1) = do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just clean up directly here. Don't perform unnecessary actions.
65496a0
to
b8c2fa9
Compare
@@ -156,6 +156,13 @@ lpackArraysChunksOf n (Fold step1 initial1 extract1) = | |||
FL.Partial rr -> extract1 rr | |||
FL.Done _ -> return () | |||
|
|||
clean (Tuple' Nothing r1) = clean1 r1 | |||
clean (Tuple' (Just buf) r1) = do | |||
r <- step1 r1 buf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary action?
-- TODO | ||
-- 1. Rename mkFold-ish combinators | ||
-- 1. Add cleanup based smart constructors | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need suggestions on naming.
@@ -434,10 +465,14 @@ toList = mkAccum (\f x -> f . (x :)) id ($ []) | |||
-- Instances | |||
------------------------------------------------------------------------------ | |||
|
|||
-- XXX The reason I used "Monad m" is because it is used by "cleanup". I could | |||
-- have used applicative for nocleanup but I don't think it really matters. | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this line after review.
-- TODO Parsers will also have a cleanup action. The correct behaviour now is | ||
-- for the parsers to clean up the Fold resources while extracting. This is | ||
-- omitted now as parser will have a seperate cleanup later. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove after review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could clean up when extracting.
@@ -1751,6 +1751,7 @@ data SessionState t m k a b = SessionState | |||
, sessionOutputStream :: t (m :: Type -> Type) (k, b) -- ^ Completed sessions | |||
} | |||
|
|||
-- XXX Need to check where to cleanup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still incomplete. I Will get back to this or the reviewer can help me out if the info is known.
extract () = liftIO $ sendStop svar winfo | ||
extract () = return () | ||
|
||
cleanup () = liftIO $ sendStop svar winfo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the effects
extract _ = return () | ||
|
||
cleanup True = liftIO $ sendStop svar winfo | ||
cleanup False = return () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the effects of this.
@@ -352,21 +352,27 @@ writeChunks | |||
=> (Word8, Word8, Word8, Word8) | |||
-> PortNumber | |||
-> Fold m (Array Word8) () | |||
writeChunks addr port = Fold step initial extract | |||
writeChunks addr port = Fold step initial extract cleanup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cleanup internal fold in initial on exception?
b8c2fa9
to
60f88bb
Compare
@@ -615,14 +615,22 @@ lpackArraysChunksOf n (Fold step1 initial1 extract1) = | |||
FL.Partial rr -> extract1 rr | |||
FL.Done _ -> return () | |||
|
|||
clean (Tuple3' Nothing' _ r1) = clean1 r1 | |||
clean (Tuple3' (Just' buf) boff r1) = do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary action?
Fixed by #2427 |
classifySessionsBy