This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Implement CRef primops

  • Loading branch information...
barrucadu committed Oct 15, 2017
1 parent 2070bdf commit 188eec562f619c26fe117dd891ff86befc27b5a2
Showing with 12 additions and 0 deletions.
  1. +12 −0 Test/MiniFu.hs
@@ -159,6 +159,18 @@ stepThread tid (threads, idsrc) = case M.lookup tid threads of
C.writeCRef ref Nothing
pure (goto (k a) (unblock mvid threads), idsrc)
Nothing -> pure (block (Just mvid) threads, idsrc)
go (NewCRef a k) = do
ref <- C.newCRef a
pure (goto (k (CRef ref)) threads, idsrc)
go (ReadCRef (CRef ref) k) = do
cur <- C.readCRef ref
pure (goto (k cur) threads, idsrc)
go (WriteCRef (CRef ref) a k) = do
C.writeCRef ref a
pure (goto k threads, idsrc)
go (ModifyCRef (CRef ref) f k) = do
new <- C.atomicModifyCRef ref f
pure (goto (k new) threads, idsrc)
go (Stop mx) = do
mx
pure (M.delete tid threads, idsrc)

0 comments on commit 188eec5

Please sign in to comment.