1-- WARNING: No guarantees that this works properly yet!
3module System.Concurrency.Process
5import System.Concurrency.Raw
10data ProcID msg = MkPID Ptr
12-- Type safe message passing programs. Parameterised over the type of
13-- message which can be send, and the return type.
15data Process : (msgType : Set) -> Set -> Set where
16 lift : IO a -> Process msg a
18instance Monad (Process msg) where
19 return = lift . return
20 (lift io) >>= k = lift (do x <- io
24run : Process msg x -> IO x
27-- Get current process ID
29myID : Process msg (ProcID msg)
30myID = lift (return (MkPID prim__vm))
32-- Send a message to another process
34send : ProcID msg -> msg -> Process msg ()
35send (MkPID p) m = lift (sendToThread p (prim__vm, m))
37-- Return whether a message is waiting in the queue
39msgWaiting : Process msg Bool
40msgWaiting = lift checkMsgs
42-- Receive a message - blocks if there is no message waiting
45recv {msg} = do (senderid, m) <- lift get
47 where get : IO (Ptr, msg)
50-- receive a message, and return with the sender's process ID.
52recvWithSender : Process msg (ProcID msg, msg)
54 = do (senderid, m) <- lift get
55 return (MkPID senderid, m)
56 where get : IO (Ptr, msg)
59create : |(thread : Process msg ()) -> Process msg (ProcID msg)
60create (lift p) = do ptr <- lift (fork p)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list