summaryrefslogtreecommitdiff
path: root/simulation.scm
diff options
context:
space:
mode:
Diffstat (limited to 'simulation.scm')
-rw-r--r--simulation.scm17
1 files changed, 16 insertions, 1 deletions
diff --git a/simulation.scm b/simulation.scm
index 09cc16d..01bc347 100644
--- a/simulation.scm
+++ b/simulation.scm
@@ -25,9 +25,21 @@
(begin exp ...)
(loop)))
+;; Synchronized logger
+(define *output-channel* (make-channel))
+(define (logger)
+ (forever
+ (let ((msg (get-message *output-channel*)))
+ (display msg))))
+
(define (ll f . data)
(let ((now (gettimeofday)))
- (format #t "~a~a - ~?~%" (car now) (cdr now) f data)))
+ (spawn-fiber
+ (lambda ()
+ (put-message
+ *output-channel*
+ (format #f "~a~a - ~?~%" (car now) (cdr now) f data))))))
+
;; type can be:
;; 'start
@@ -197,6 +209,9 @@
(define (run-simulation)
+ ;; We need a synchronized logger running in a fiber
+ (spawn-fiber logger)
+
(let* ((radio-chn (make-channel))
(end-devices (make-hash-table))
(gateways (make-hash-table)))