Commit 0df4cf1d authored by Steffen Michels's avatar Steffen Michels

fix memory leak in reduct store of parallel task children:...

fix memory leak in reduct store of parallel task children: taskInstanceParallelTaskListTask provides tasks with dynamic values, as the typed version added a layer of conversion functions with each task reduct update
parent 172c15a2
Pipeline #36961 passed with stage
in 6 minutes and 55 seconds
......@@ -135,7 +135,7 @@ taskInstanceParallelTaskListTasks :: SDSLens (TaskId,TaskListFilter) (Map TaskI
taskInstanceParallelTaskListItem :: SDSLens (TaskId,TaskId,Bool) TaskMeta TaskMeta
taskInstanceParallelTaskListValue :: SDSLens (TaskId,TaskId) (TaskValue a) (TaskValue a) | iTask a
taskInstanceParallelTaskListTask :: SDSLens (TaskId,TaskId) (Task a) (Task a) | iTask a
taskInstanceParallelTaskListTask :: SDSLens (TaskId,TaskId) (Task DeferredJSON) (Task DeferredJSON)
//Interface used during the evalation of toplevel tasks
//Filtered views on the instance index
......@@ -201,3 +201,6 @@ createDocument :: !String !String !String !*IWorld -> (!MaybeError FileError
loadDocumentContent :: !DocumentId !*IWorld -> (!Maybe String, !*IWorld)
loadDocumentMeta :: !DocumentId !*IWorld -> (!Maybe Document, !*IWorld)
documentLocation :: !DocumentId !*IWorld -> (!FilePath,!*IWorld)
encodeTaskValue :: (TaskValue a) -> TaskValue DeferredJSON | iTask a
decodeTaskValue :: (TaskValue DeferredJSON) -> TaskValue a | iTask a
......@@ -459,11 +459,14 @@ where
notify (listId,taskId) _ _ _ = True
reducer p ws = read p ws
taskInstanceParallelTaskListTask :: SDSLens (TaskId,TaskId) (Task a) (Task a) | iTask a
taskInstanceParallelTaskListTask
= sdsLens "taskInstanceParallelTaskListTask" param (SDSRead read) (SDSWrite write) (SDSNotifyConst notify)
(Just reducer) taskInstanceParallelTaskListTasks
taskInstanceParallelTaskListTask :: SDSLens (TaskId,TaskId) (Task DeferredJSON) (Task DeferredJSON)
taskInstanceParallelTaskListTask =
sdsLens
"taskInstanceParallelTaskListTask" param (SDSRead read) (SDSWrite write) (SDSNotifyConst notify) (Just reducer)
(sdsTranslate "taskInstanceParallelTaskListTasksDynamic" paramTasks taskListDynamicTaskData)
where
paramTasks (listId,listfilter) = (listId,listId,listfilter,defaultValue)
param (listId,taskId)
= (listId,{TaskListFilter|fullTaskListFilter & onlyTaskId=Just [taskId]})
read p=:(listId,taskId) tasks = case 'DM'.get taskId tasks of
......
......@@ -330,7 +330,6 @@ evalParallelTasks :: !Event !TaskEvalOpts
[(TaskId, TaskResult a)] [TaskMeta] (Map TaskId (TaskValue a)) !*IWorld
->
(MaybeError TaskException [TaskResult a],!*IWorld) | iTask a
evalParallelTasks event evalOpts=:{TaskEvalOpts|taskId=listId} conts completed [] values iworld
//(re-)read the tasklist to check if it contains items we have not yet evaluated
# filter = {TaskListFilter|fullTaskListFilter & notTaskId = Just (map fst completed)} //Explicitly exclude the tasks we already evaluated
......@@ -350,7 +349,7 @@ evalParallelTasks event evalOpts=:{TaskEvalOpts|taskId=listId} conts completed [
| mbError =:(Error _) = (liftError mbError,iworld)
# taskId = state.TaskMeta.taskId
//Store the task function
# (mbError,iworld) = (write (fromJust mbTask) (sdsFocus (listId,taskId) taskInstanceParallelTaskListTask) EmptyContext iworld)
# (mbError,iworld) = (write (fromJust mbTask @? encodeTaskValue) (sdsFocus (listId,taskId) taskInstanceParallelTaskListTask) EmptyContext iworld)
| mbError =:(Error _) = (liftError mbError,iworld)
= evalParallelTasks ResetEvent evalOpts conts completed [state] values iworld //Continue
(err,iworld) = (liftError err, iworld)
......@@ -425,6 +424,7 @@ where
//If the exception can not be handled, don't continue evaluating just stop
= (Ok (ExceptionResult e),iworld)
(ValueResult val evalInfo=:{TaskEvalInfo|lastEvent,removedTasks} change task, iworld)
# val = decodeTaskValue val
//Isolate changes to implicit task attributes
# taskAttributeUpdate = case change of
ReplaceUI (UI _ attributes _) = const attributes
......@@ -436,7 +436,7 @@ where
| mbManagementMeta=:(Error _) = (Error (fromError mbManagementMeta),iworld)
# change = addManagementAttributeChanges (directResult $ fromOk mbManagementMeta) change
//Construct task result
# result = ValueResult val evalInfo change task
# result = ValueResult val evalInfo change (task @? decodeTaskValue)
//Check if the value changed
# valueChanged = val =!= value
//Write the new reduct
......@@ -517,9 +517,10 @@ destroyEmbeddedParallelTask listId=:(TaskId instanceNo _) taskId iworld=:{curren
(Error e,iworld) = ([e], DestroyedResult,iworld)
(Ok (ReadingDone (Task eval)),iworld)
= case eval DestroyEvent {mkEvalOpts & noUI = True, taskId=taskId} iworld of
(res=:(DestroyedResult),iworld) = ([],res,iworld)
(res=:(ExceptionResult e),iworld) = ([e],DestroyedResult,iworld)
(res,iworld) = ([exception "destroyEmbeddedParallelTask: unexpected result"],DestroyedResult,iworld)
(DestroyedResult, iworld) = ([], DestroyedResult, iworld)
(ExceptionResult e, iworld) = ([e], DestroyedResult, iworld)
(_, iworld) =
([exception "destroyEmbeddedParallelTask: unexpected result"],DestroyedResult,iworld)
// 2. Remove the task evaluation function
# (errs,iworld) = case modify (\tasks -> 'DM'.del taskId tasks)
(sdsFocus (listId,listId,defaultValue,defaultValue) taskListDynamicTaskData) EmptyContext iworld of
......@@ -626,7 +627,7 @@ where
| mbError =:(Error _) = (liftError mbError,iworld)
//If the task is an embedded one, we also need to store the task function
| mbTask =:(Just _)
# (mbError,iworld) = (write (fromJust mbTask) (sdsFocus (listId,taskId) taskInstanceParallelTaskListTask) EmptyContext iworld)
# (mbError,iworld) = (write (fromJust mbTask @? encodeTaskValue) (sdsFocus (listId,taskId) taskInstanceParallelTaskListTask) EmptyContext iworld)
| mbError =:(Error _) = (liftError mbError,iworld)
= (Ok taskId, iworld)
= (Ok taskId, iworld)
......
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