on master help sign in
rename resumeContext to composeContext
commit3103c1c82e269106c1c8a2c614f52f852f1038b5 authorHarendra Kumar <harendra.kumar@gmail.com> dateMon 26 Jun 2017, 00:15 (9 years ago) parent76cd2cc
2 files changed+13−10
src/Strands/Context.hs+12−8 src/Strands/Threads.hs+1−2
src/Strands/Context.hs+12−8
@@ -8,7 +8,7 @@ module Strands.Context
88 , initContext
99 , saveContext
1010 , restoreContext
11− , resumeContext
11+ , composeContext
1212 , setContextMailBox
1313 , takeContextMailBox
1414 , getCtxResultDest
@@ -151,7 +151,10 @@ setLocation :: Monad m => Location -> StateT Context m ()
151151setLocation loc = Lazy.modify $ \Context { .. } -> Context { location = loc, .. }
152152
153153------------------------------------------------------------------------------
154−-- Saving and restoring the context of a computation
154+-- Saving and restoring the context of a computation. We perform the monadic
155+-- computation one step at a time storing the context of where we are in the
156+-- computation. At any point the remaining computation can be fully recovered
157+-- from this context.
155158------------------------------------------------------------------------------
156159
157160-- Save the 'm' and 'f', in case we migrate to a new thread before the current
@@ -179,13 +182,14 @@ restoreContext x = do
179182
180183 return mres
181184
182−-- | Resume execution of the computation from a given context. We can retrieve
183−-- a context at any point and resume that context at some later point, upon
184−-- resumption we start executing again from the same point where the context
185−-- was retrieved.
185+-- | We can retrieve a context at any point and resume that context at some
186+-- later point, upon resumption we start executing again from the same point
187+-- where the context was retrieved from.
186188--
187−resumeContext :: (MonadIO m, MonadPlus m) => Context -> m a
188−resumeContext Context { currentm = m
189+-- This function composes the stored context to recover the computation.
190+--
191+composeContext :: (MonadIO m, MonadPlus m) => Context -> m a
192+composeContext Context { currentm = m
189193 , fstack = fs
190194 } =
191195 unsafeCoerce m >>= composefStack (unsafeCoerce fs)
src/Strands/Threads.hs+1−2
@@ -73,8 +73,7 @@ import Strands.Context
7373
7474runContext :: MonadIO m => Context -> StateT Context m ()
7575runContext ctx = do
76− -- XXX rename to buildContext or buildState?
77− let s = runAsyncT (resumeContext ctx)
76+ let s = runAsyncT (composeContext ctx)
7877 _ <- lift $ runStateT s ctx
7978 return ()
8079