(define actor-table (make-hash-table))
(define (make-actor-with-address address behaviour)
+ (if trace-enabled
+ (print "Making actor with address " address))
(hash-table-set! actor-table address behaviour)
address)
(let ((value (apply behaviour (cons address message))))
(case value
((sleep) 'do-nothing)
- ((done) (hash-table-delete! actor-table address))
+ ((done)
+ (if trace-enabled
+ (print "Deleting actor " address))
+ (hash-table-delete! actor-table address))
(else
(if trace-enabled
(print "Updating behaviour of " address))
(load "actors.scm")
+(define trace-enabled #t)
+
(define factorial
(make-actor-with-address 'factorial
(lambda (self customer . message)
(load "actors.scm")
+(define trace-enabled #t)
+
(define factorial
(make-actor-with-address 'factorial
(lambda (self customer n)
(lambda (self m)
(send-message customer (* n m))
'done))))
- (send-message self fact-acc (- n 1))
- 'sleep)))))
+ (send-message self fact-acc (- n 1))))
+ 'sleep)))
(define println
(make-actor-with-address 'println
'sleep)))
(send-message factorial println 5)
+(send-message factorial println 7)
(run)