Commit c37b4d5b authored by Mart Lubbers's avatar Mart Lubbers

Handle errors in dequeueEvent

parent e521c36e
......@@ -58,8 +58,9 @@ processEvents max iworld
| max <= 0 = (Ok (), iworld)
| otherwise
= case dequeueEvent iworld of
(Nothing,iworld) = (Ok (),iworld)
(Just (instanceNo,event),iworld)
(Error e, iworld) = (Error e, iworld)
(Ok Nothing, iworld) = (Ok (), iworld)
(Ok (Just (instanceNo,event)), iworld)
= case evalTaskInstance instanceNo event iworld of
(Ok taskValue,iworld)
= processEvents (max - 1) iworld
......
......@@ -162,7 +162,7 @@ queueRefresh :: ![(!TaskId, !String)] !*IWorld -> *IWorld
/**
* Dequeue a task event
*/
dequeueEvent :: !*IWorld -> (!Maybe (InstanceNo,Event),!*IWorld)
dequeueEvent :: !*IWorld -> (!MaybeError TaskException (Maybe (InstanceNo,Event)),!*IWorld)
/**
* Queue ui change task output
......
......@@ -551,16 +551,15 @@ queueRefresh tasks iworld
# iworld = foldl (\w (t,r) -> queueEvent (toInstanceNo t) (RefreshEvent ('DS'.singleton t) r) w) iworld tasks
= iworld
// TODO: Handle errors
dequeueEvent :: !*IWorld -> (!Maybe (InstanceNo,Event),!*IWorld)
dequeueEvent :: !*IWorld -> (!MaybeError TaskException (Maybe (InstanceNo,Event)),!*IWorld)
dequeueEvent iworld
= case 'SDS'.read taskEvents 'SDS'.EmptyContext iworld of
(Error e, iworld) = (Nothing, iworld)
(Error e, iworld) = (Error e, iworld)
(Ok ('SDS'.ReadingDone queue), iworld)
# (val, queue) = 'DQ'.dequeue queue
= case 'SDS'.write queue taskEvents 'SDS'.EmptyContext iworld of
(Error e, iworld) = (Nothing, iworld)
(Ok WritingDone, iworld) = (val, iworld)
(Error e, iworld) = (Error e, iworld)
(Ok WritingDone, iworld) = (Ok val, iworld)
clearEvents :: !InstanceNo !*IWorld -> *IWorld
clearEvents instanceNo 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