38 | 38 |
|
39 | 39 |
| (robin (0 1) ((small (0 1) *) (concurrency (0 1) *))
|
40 | 40 |
| (myself 123))
|
41 | |
? uncaught exception: (illegal-arguments 123)
|
|
41 |
? uncaught exception: (illegal-arguments (123))
|
42 | 42 |
|
43 | 43 |
### `pid?` ###
|
44 | 44 |
|
|
58 | 58 |
|
59 | 59 |
| (robin (0 1) ((small (0 1) *) (concurrency (0 1) *))
|
60 | 60 |
| (pid?))
|
61 | |
? uncaught exception: (illegal-arguments)
|
|
61 |
? uncaught exception: (illegal-arguments ())
|
62 | 62 |
|
63 | 63 |
| (robin (0 1) ((small (0 1) *) (concurrency (0 1) *))
|
64 | 64 |
| (pid? 200 500))
|
65 | |
? uncaught exception: (illegal-arguments 200 500)
|
|
65 |
? uncaught exception: (illegal-arguments (200 500))
|
66 | 66 |
|
67 | 67 |
### `spawn!` ###
|
68 | 68 |
|
|
86 | 86 |
|
87 | 87 |
| (robin (0 1) ((small (0 1) *) (concurrency (0 1) *))
|
88 | 88 |
| (spawn!))
|
89 | |
? uncaught exception: (illegal-arguments)
|
|
89 |
? uncaught exception: (illegal-arguments ())
|
90 | 90 |
|
91 | 91 |
| (robin (0 1) ((small (0 1) *) (concurrency (0 1) *))
|
92 | 92 |
| (spawn! cheesecake))
|
93 | |
? uncaught exception: (illegal-arguments cheesecake)
|
|
93 |
? uncaught exception: (illegal-arguments (cheesecake))
|
94 | 94 |
|
95 | 95 |
| (robin (0 1) ((small (0 1) *) (concurrency (0 1) *))
|
96 | 96 |
| (spawn! (fun (x) 0) (fun (x) 1)))
|
97 | |
? uncaught exception: (illegal-arguments (fun (x) 0) (fun (x) 1))
|
|
97 |
? uncaught exception: (illegal-arguments ((fun (x) 0) (fun (x) 1)))
|
98 | 98 |
|
99 | 99 |
| (robin (0 1) ((small (0 1) *) (concurrency (0 1) *))
|
100 | 100 |
| (spawn! (fun (x) 0) (fun (x) 1)
|
101 | 101 |
| (fun (x) 2) (fun (x) 3)))
|
102 | |
? uncaught exception: (illegal-arguments (fun (x) 0) (fun (x) 1) (fun (x) 2) (fun (x) 3))
|
|
102 |
? uncaught exception: (illegal-arguments ((fun (x) 0) (fun (x) 1) (fun (x) 2) (fun (x) 3)))
|
103 | 103 |
|
104 | 104 |
The first argument to `spawn!` must be a symbol.
|
105 | 105 |
|
106 | 106 |
| (robin (0 1) ((small (0 1) *) (concurrency (0 1) *))
|
107 | 107 |
| (spawn! #f (literal ok) 123))
|
108 | |
? uncaught exception: (illegal-arguments #f (literal ok) 123)
|
|
108 |
? uncaught exception: (illegal-arguments (#f (literal ok) 123))
|
109 | 109 |
|
110 | 110 |
### `send!` ###
|
111 | 111 |
|
|
123 | 123 |
|
124 | 124 |
| (robin (0 1) ((small (0 1) *) (concurrency (0 1) *))
|
125 | 125 |
| (send! (literal eggs) (literal spam) (literal ok)))
|
126 | |
? uncaught exception: (expected-pid . eggs)
|
|
126 |
? uncaught exception: (expected-pid eggs)
|
127 | 127 |
|
128 | 128 |
`send!` expects exactly three arguments.
|
129 | 129 |
|
130 | 130 |
| (robin (0 1) ((small (0 1) *) (concurrency (0 1) *))
|
131 | 131 |
| (spawn! worker (literal ok)
|
132 | 132 |
| (send! worker worker)))
|
133 | |
? uncaught exception: (illegal-arguments worker worker)
|
|
133 |
? uncaught exception: (illegal-arguments (worker worker))
|
134 | 134 |
|
135 | 135 |
| (robin (0 1) ((small (0 1) *) (concurrency (0 1) *))
|
136 | 136 |
| (spawn! worker (literal ok)
|
137 | 137 |
| (send! worker worker worker worker)))
|
138 | |
? uncaught exception: (illegal-arguments worker worker worker worker)
|
|
138 |
? uncaught exception: (illegal-arguments (worker worker worker worker))
|
139 | 139 |
|
140 | 140 |
### `recv!` ###
|
141 | 141 |
|
|
158 | 158 |
| (bind parent (myself)
|
159 | 159 |
| (spawn! worker (send! parent (literal lettuce) (literal ok))
|
160 | 160 |
| (recv! (pair 7 ()) 9))))
|
161 | |
? uncaught exception: (illegal-arguments (pair 7 ()) 9)
|
|
161 |
? uncaught exception: (illegal-arguments ((pair 7 ()) 9))
|
162 | 162 |
|
163 | 163 |
`recv!` expects exactly two arguments.
|
164 | 164 |
|
|
166 | 166 |
| (bind parent (myself)
|
167 | 167 |
| (spawn! worker (send! parent (literal lettuce) (literal ok))
|
168 | 168 |
| (recv! message))))
|
169 | |
? uncaught exception: (illegal-arguments message)
|
|
169 |
? uncaught exception: (illegal-arguments (message))
|
170 | 170 |
|
171 | 171 |
| (robin (0 1) ((small (0 1) *) (concurrency (0 1) *))
|
172 | 172 |
| (bind parent (myself)
|
173 | 173 |
| (spawn! worker (send! parent (literal lettuce) (literal ok))
|
174 | 174 |
| (recv! message message message))))
|
175 | |
? uncaught exception: (illegal-arguments message message message)
|
|
175 |
? uncaught exception: (illegal-arguments (message message message))
|
176 | 176 |
|
177 | 177 |
Tests for both `send!` and `recv!` follow.
|
178 | 178 |
|
|
267 | 267 |
|
268 | 268 |
| (robin (0 1) ((small (0 1) *) (concurrency (0 1) *))
|
269 | 269 |
| (msgs? #t))
|
270 | |
? uncaught exception: (illegal-arguments #t)
|
|
270 |
? uncaught exception: (illegal-arguments (#t))
|
271 | 271 |
|
272 | 272 |
### `call!` ###
|
273 | 273 |
|
|
284 | 284 |
| (pair (pair tag (pair (literal reply) ()))
|
285 | 285 |
| (pair (pair tag (pair payload ())) ()))) 0)))
|
286 | 286 |
| (call! worker this-tag (literal this-payload) reply
|
287 | |
| (pair (literal reply-was) reply))))
|
288 | |
= (reply-was this-tag this-payload)
|
|
287 |
| (pair (literal reply-was) (pair reply ())))))
|
|
288 |
= (reply-was (this-tag this-payload))
|
289 | 289 |
|
290 | 290 |
The pid and tag in the return message must match, or `call!` will
|
291 | 291 |
not finish. Note: this is an awful test, because an implementation
|
|
301 | 301 |
| (pair (pair tag (pair (literal reply) ()))
|
302 | 302 |
| (pair (pair tag (pair payload ())) ()))) 0)))
|
303 | 303 |
| (call! worker this-tag (literal this-payload) reply
|
304 | |
| (pair (literal reply-was) reply)))))
|
|
304 |
| (pair (literal reply-was) (pair reply ()))))))
|
305 | 305 |
? thread blocked indefinitely in an MVar operation
|
306 | 306 |
|
307 | 307 |
| (robin (0 1) ((small (0 1) *) (concurrency (0 1) *))
|
|
314 | 314 |
| (pair (pair (literal some-other-tag) (literal reply))
|
315 | 315 |
| (pair (pair tag payload) ()))) 0)))
|
316 | 316 |
| (call! worker this-tag (literal this-payload) reply
|
317 | |
| (pair (literal reply-was) reply)))))
|
|
317 |
| (pair (literal reply-was) (pair reply ()))))))
|
318 | 318 |
? thread blocked indefinitely in an MVar operation
|
319 | 319 |
|
320 | 320 |
If `call!` receives an exception message, it will `raise` that
|
|
325 | 325 |
| (robin (0 1) ((small (0 1) *) (concurrency (0 1) *))
|
326 | 326 |
| (spawn! worker
|
327 | 327 |
| (recv! message
|
328 | |
| (let ((send!er (head message))
|
|
328 |
| (let ((sender (head message))
|
329 | 329 |
| (tag (head (tail message)))
|
330 | 330 |
| (payload (head (tail (tail message)))))
|
331 | 331 |
| (head (literal argh))))
|
332 | 332 |
| (call! worker this-tag (literal this-payload) reply
|
333 | 333 |
| (pair (literal reply-was) reply))))
|
334 | |
? uncaught exception: (expected-pair . argh)
|
|
334 |
? uncaught exception: (expected-list argh)
|
335 | 335 |
|
336 | 336 |
`call!` expects its first argument to be a pid.
|
337 | 337 |
|
338 | 338 |
| (robin (0 1) ((small (0 1) *) (concurrency (0 1) *))
|
339 | 339 |
| (call! (literal worker) this-tag (literal this-payload) reply
|
340 | 340 |
| (pair (literal reply-was) reply)))
|
341 | |
? uncaught exception: (expected-pid . worker)
|
|
341 |
? uncaught exception: (expected-pid worker)
|
342 | 342 |
|
343 | 343 |
`call!` expects its second argument to be a symbol.
|
344 | 344 |
|
345 | 345 |
| (robin (0 1) ((small (0 1) *) (concurrency (0 1) *))
|
346 | 346 |
| (call! (myself) #f (literal this-payload) reply
|
347 | 347 |
| (pair (literal reply-was) reply)))
|
348 | |
? uncaught exception: (illegal-arguments (myself) #f (literal this-payload) reply (pair (literal reply-was) reply))
|
|
348 |
? uncaught exception: (illegal-arguments ((myself) #f (literal this-payload) reply (pair (literal reply-was) reply)))
|
349 | 349 |
|
350 | 350 |
`call!` expects its fourth argument to be an identifier.
|
351 | 351 |
|
352 | 352 |
| (robin (0 1) ((small (0 1) *) (concurrency (0 1) *))
|
353 | 353 |
| (call! (myself) this-tag (literal this-payload) #f
|
354 | 354 |
| (pair (literal reply-was) reply)))
|
355 | |
? uncaught exception: (illegal-arguments (myself) this-tag (literal this-payload) #f (pair (literal reply-was) reply))
|
|
355 |
? uncaught exception: (illegal-arguments ((myself) this-tag (literal this-payload) #f (pair (literal reply-was) reply)))
|
356 | 356 |
|
357 | 357 |
### `respond!` ###
|
358 | 358 |
|