X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?p=sam.git;a=blobdiff_plain;f=sam.scm;fp=sam.scm;h=a8ea67b9e1afb37cb001197f8794865f2bb93d01;hp=f09914e835f1d258c743666336f67c51149ae94d;hb=fb6698bac8e29c6579a998f59c26192274b9404e;hpb=dd9d28a6e6bb76533890d84cb48900352ff8fa68 diff --git a/sam.scm b/sam.scm index f09914e..a8ea67b 100644 --- a/sam.scm +++ b/sam.scm @@ -42,6 +42,11 @@ (lambda () (if trace (apply log-msg args))))) +(define (->stringrep arg) + (with-output-to-string + (lambda () + (write arg)))) + ;; Behaviours ;; (See also macros defined in sam-macros.scm.) @@ -100,7 +105,7 @@ (define (deliver-message address . message) (let ((id (address-id address))) - (log-trace "DELIVERING to " id ": " message) + (log-trace "DELIVERING to " id ": " (->stringrep message)) (let loop ((beh (hash-table-ref/default actor-table id #f))) (if beh (condition-case @@ -114,9 +119,9 @@ (else (log-msg "Warning: behaviour of actor " id " returned invalid value."))) (o (exn) - (log-msg "Warning: actor " id " crashed evaluating message " message) + (log-msg "Warning: actor " id " crashed evaluating message " (->stringrep message)) (print-error-message o))) - (log-msg "Warning: DISCARDING message to unknown actor " id ": " message))))) + (log-msg "Warning: DISCARDING message to unknown actor " id ": " (->stringrep message)))))) ;; Scheduler @@ -126,7 +131,7 @@ (define local-queue (make-fifo)) (define (send-message address . message) - (log-trace "SENDING to " address ": " message) + (log-trace "SENDING to " address ": " (->stringrep message)) (apply (if (address-local? address) send-local-message send-network-message) @@ -217,23 +222,23 @@ ;; System initialization -(define system-beh - (make-beh (self) - (('shutdown) => - (log-msg "System actor received shutdown message.") - (exit 0) - 'done) - - (('print strings ...) => - (apply print strings) - 'sleep) - - (('read reader) => - (mutex-lock! reader-queue-mutex) - (fifo-push reader-queue reader) - (mutex-unlock! reader-available-mutex) - (mutex-unlock! reader-queue-mutex) - 'sleep))) +(define-beh system-beh + (self) + (('shutdown) => + (log-msg "System actor received shutdown message.") + (exit 0) + 'done) + + (('print strings ...) => + (apply print strings) + 'sleep) + + (('read reader) => + (mutex-lock! reader-queue-mutex) + (fifo-push reader-queue reader) + (mutex-unlock! reader-available-mutex) + (mutex-unlock! reader-queue-mutex) + 'sleep)) (define (boot-sam) (start-console)