Last active
August 29, 2015 14:26
-
-
Save Idorobots/d4b10321df0f931a73b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(letrec ((monitor (lambda () | |
(task-info) | |
(sleep 10000) | |
(monitor))) | |
(notify (lambda (prefix t) | |
(assert! `(notify ,prefix ,(random))) | |
(sleep t) | |
(notify prefix t))) | |
(listen (lambda () | |
(let ((m (recv))) | |
(display "Complex event: ") | |
(display m) | |
(newline) | |
(listen))))) | |
(notify-whenever (spawn listen) | |
'(filter (and (?notify foo ?foo) | |
(?notify bar ?bar)) | |
(>= ?foo 0.5) | |
(< ?foo 0.75) | |
(<= ?bar 0.1))) | |
(spawn (lambda () | |
(notify 'foo 1000))) | |
(spawn (lambda () | |
(notify 'bar 5000))) | |
(monitor)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Compiled code: | |
'(let ((__monitor '()) (__notify '()) (__listen '())) | |
(do (set! | |
__monitor | |
(lambda (__cont206) | |
(__task_info | |
(lambda (__value207) | |
(__sleep | |
10000 | |
(lambda (__value208) | |
(__monitor | |
(lambda (__value209) | |
(do __value207 | |
__value208 | |
(&yield-cont __cont206 __value209)))))))))) | |
(set! | |
__notify | |
(lambda (__prefix __t __cont210) | |
(__random | |
(lambda (__value215) | |
(__cons | |
__value215 | |
'() | |
(lambda (__value214) | |
(__cons | |
__prefix | |
__value214 | |
(lambda (__value213) | |
(__cons | |
'notify | |
__value213 | |
(lambda (__value212) | |
(__assertBANG | |
__value212 | |
(lambda (__value211) | |
(__sleep | |
__t | |
(lambda (__value216) | |
(__notify | |
__prefix | |
__t | |
(lambda (__value217) | |
(do __value211 | |
__value216 | |
(&yield-cont | |
__cont210 | |
__value217)))))))))))))))))) | |
(set! __listen | |
(lambda (__cont218) | |
(__recv | |
(lambda (__value225) | |
((lambda (__m __cont220) | |
(__display | |
"Complex event: " | |
(lambda (__value221) | |
(__display | |
__m | |
(lambda (__value222) | |
(__newline | |
(lambda (__value223) | |
(__listen | |
(lambda (__value224) | |
(do __value221 | |
__value222 | |
__value223 | |
(&yield-cont __cont220 __value224))))))))))) | |
__value225 | |
(lambda (__value219) (&yield-cont __cont218 __value219))))))) | |
(__spawn | |
__listen | |
(lambda (__value227) | |
(__notify_whenever | |
__value227 | |
'(filter | |
(and (?notify foo ?foo) (?notify bar ?bar)) | |
(>= ?foo 0.5) | |
(< ?foo 0.75) | |
(<= ?bar 0.1)) | |
(lambda (__value226) | |
(__spawn | |
(lambda (__cont229) | |
(__notify | |
'foo | |
1000 | |
(lambda (__value230) (&yield-cont __cont229 __value230)))) | |
(lambda (__value228) | |
(__spawn | |
(lambda (__cont232) | |
(__notify | |
'bar | |
5000 | |
(lambda (__value233) (&yield-cont __cont232 __value233)))) | |
(lambda (__value231) | |
(__monitor | |
(lambda (__value234) | |
(do __value226 | |
__value228 | |
__value231 | |
__value234))))))))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment