Skip to content

Commit

Permalink
feat(runtime): start on event log
Browse files Browse the repository at this point in the history
  • Loading branch information
symbiont-stevan-andjelkovic committed Jun 3, 2021
1 parent 43795e7 commit 92e7615
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/runtime-prototype/src/StuntDouble/ActorMap.hs
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,8 @@ makeEventLoop time seed tk name = do
NamedPipe fp -> namedPipeTransport fp name
Http port -> httpTransport port
ls <- initLoopState name time seed t
-- XXX: all these async handlers introduce non-determinism, we would need a
-- way to synchronise them if we wanted complete determinism...
aInHandler <- async (handleInbound ls)
aAsyncIOHandler <- async (handleAsyncIO ls)
aEvHandler <- async (handleEvents ls)
Expand Down Expand Up @@ -514,7 +516,7 @@ handleEvents ls = forever go
putStrLn ("handleEvents: exception: " ++ show ex)

handleEvent :: Event -> EventLoop -> IO ()
handleEvent (Action a) ls = act' ls [a]
handleEvent (Action a) ls = act' ls [a]
handleEvent (Reaction r) ls = do
m <- reactIO r (lsAsyncState ls)
case m of
Expand Down
24 changes: 23 additions & 1 deletion src/runtime-prototype/src/StuntDouble/Log.hs
Original file line number Diff line number Diff line change
@@ -1,11 +1,33 @@
module StuntDouble.Log where

import StuntDouble.Message
import StuntDouble.Reference
import StuntDouble.Actor.State

------------------------------------------------------------------------

newtype Log = Log [LogEntry]

data LogEntry
= LogEntry
= Spawned LocalRef State
| Turn TurnData
| ClientRequest
| ClientResponse

data TurnData = TurnData
{ tdActor :: LocalRef
, tdBeforeState :: State
, tdMessage :: Message
, tdActions :: [ActionLogEntry]
, tdLogs :: [LogLines]
, tdAfterState :: State
, tdLogicalTime :: Int
, tdSimulatedTime :: Int -- XXX: UTCTime
, tdReply :: Message
}

data ActionLogEntry = XXX
data LogLines = YYY

emptyLog :: Log
emptyLog = Log []

0 comments on commit 92e7615

Please sign in to comment.