git @ Cat's Eye Technologies Robin / 409fe85
Uncaught exceptions in subprocesses send message to parent. Cat's Eye Technologies 13 years ago
3 changed file(s) with 17 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
113113
114114 ### Concurrency and Exceptions ###
115115
116 * Establish the relationship between exceptions and processes -- if a
117 process raises an exception that it does not catch, it should send
118 a message to its parent (the process that spawned it.)
119
120116 * Fuller tests for exceptions.
121117
122118 * Add richer concurrency primitives (`call` and `respond`, which assume
5151 process has started, we set up an appropriate IEnv and evaluate
5252 the macro in that.
5353
54 TODO: the exception handler in the new IEnv should not be `stop`,
55 but rather something that sends a message to the parent.
56
57 TODO: should we put the parent in the IEnv, too?
58
5954 TODO: should the final continuation send a message to the parent
6055 too?
6156
6661 > launch chan = do
6762 > thread <- myThreadId
6863 > let parent = getPid ienv
69 > let myIenv = newIEnv (stop) thread chan
64 > let myIenv = newIEnv (makeMsgSendingExcHandler parent) thread chan
7065 > let expr = Pair macro $ Pair parent Null
7166 > eval env myIenv expr (\x -> do return Null)
7267 > return ()
68
69 > makeMsgSendingExcHandler pid =
70 > \value -> do
71 > writeChan (getChan pid) (Pair (Symbol "uncaught-exception") value)
72 > return Null
7373
7474 Now the functions exported by this Robin module.
7575
218218 | (recv message message)))
219219 = hello
220220
221 If an exception is raised, but not caught, in a process, that process
222 sends a message to this effect to the process that spawned it,
223 immediately before terminating.
224
225 | (robin (0 . 1) (small (0 . 1) concurrency (0 . 1))
226 | (bind worker (spawn (fun (parent)
227 | (bind x (head ())
228 | (send parent (literal hi) 0))))
229 | (recv message message)))
230 = (uncaught-exception expected-pair)
231
221232 ### `msgs?` ###
222233
223234 `msgs?` evaluates to `#t` if the current process has one or more messages