Verified Commit 08fdc32f authored by Camil Staps's avatar Camil Staps 🚀

Centralize task teardown: move clearTaskSDSRegistrations and clearEventsFor...

Centralize task teardown: move clearTaskSDSRegistrations and clearEventsFor into apTask for DestroyEvent and ServerInterruptedEvent
parent e3ba19a5
Pipeline #48011 passed with stages
in 9 minutes and 11 seconds
......@@ -744,7 +744,6 @@ where
= eval (ASAttached (status =: (Right True))) build (?Just newKey) event evalOpts iworld
eval _ _ _ DestroyEvent evalOpts=:{TaskEvalOpts|taskId} iworld
# iworld = clearTaskSDSRegistrations ('DS'.singleton taskId) (clearEventsFor taskId iworld)
# (_,iworld) = modify release (sdsFocus (instanceNo,False,True) taskInstance) EmptyContext iworld
= (DestroyedResult, iworld)
where
......
implementation module iTasks.WF.Definition
from iTasks.Internal.IWorld import :: IWorld
from System.Time import :: Timestamp, :: Timespec
import iTasks.WF.Derives
import iTasks.UI.Definition
import iTasks.UI.Editor
import iTasks.UI.Editor.Generic
import StdEnv
from Text.GenJSON import :: JSONNode
from Data.Map import :: Map(..)
from Data.Set import :: Set
import qualified Data.Set as Set
import Data.Functor
from System.Time import :: Timestamp, :: Timespec
import Text, Text.GenJSON
import StdEnv
import iTasks
import iTasks.Internal.TaskEval
import iTasks.Internal.TaskIO
:: Task a =: Task` (Event TaskEvalOpts *IWorld -> *(TaskResult a, *IWorld))
......@@ -21,7 +19,14 @@ Task :: !(Event TaskEvalOpts *IWorld -> *(TaskResult a, *IWorld)) -> Task a
Task f = Task` f
apTask :: !(Task a) !Event TaskEvalOpts !*IWorld -> *(TaskResult a, *IWorld)
apTask (Task` f) event opts iworld = f event opts iworld
apTask (Task` f) event opts=:{TaskEvalOpts|taskId} iworld
# (res,iworld) = f event opts iworld
| event=:DestroyEvent || event=:ServerInterruptedEvent
# iworld = clearEventsFor taskId iworld
# iworld = clearTaskSDSRegistrations ('Set'.singleton taskId) iworld
= (res, iworld)
| otherwise
= (res, iworld)
exception :: !e -> TaskException | TC, toString e
exception e = (dynamic e, toString e)
......
......@@ -108,7 +108,7 @@ evalInteract ::
evalInteract _ _ _ _ _ _ _ _ ServerInterruptedEvent _ iworld
= (DestroyedResult, iworld)
evalInteract _ _ _ _ _ _ _ _ DestroyEvent {TaskEvalOpts|taskId} iworld
= (DestroyedResult, 'SDS'.clearTaskSDSRegistrations ('DS'.singleton taskId) (clearEventsFor taskId iworld))
= (DestroyedResult, iworld)
evalInteract _ mbr ?None _ sds editor modefun writefun event=:(EditEvent eTaskId name edit) evalOpts=:{taskId,lastEval} iworld
= (ExceptionResult (exception "corrupt editor state"), iworld)
evalInteract prevChange mbr (?Just st) editorId sds editor modefun writefun event=:(EditEvent eTaskId name edit) evalOpts=:{taskId,lastEval} iworld | eTaskId == taskId
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment