From a05e3af2f36158d470b2d2e71d3136edf2fa5e86 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Tue, 12 Apr 2016 22:22:24 -0400 Subject: [PATCH] Fixup I/O --- examples/threading/many-writers.scm | 2 +- examples/threading/producer-consumer.scm | 15 ++++++++++----- examples/threading/thread-join.scm | 9 ++++++--- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/examples/threading/many-writers.scm b/examples/threading/many-writers.scm index 4daeea2e..a6dd33e0 100644 --- a/examples/threading/many-writers.scm +++ b/examples/threading/many-writers.scm @@ -6,7 +6,7 @@ (srfi 18)) (define (write-forever val) - (write val) + (display val) (write-forever val)) (define (make-writer val) diff --git a/examples/threading/producer-consumer.scm b/examples/threading/producer-consumer.scm index 9c73af95..26240fd4 100644 --- a/examples/threading/producer-consumer.scm +++ b/examples/threading/producer-consumer.scm @@ -18,24 +18,29 @@ (cond ((> n 0) (mutex-lock! *lock*) - (write (cons 'a *queue*)) + (display (cons 'a *queue*)) + (newline) (set! *queue* (->heap (cons (->heap n) *queue*))) (mutex-unlock! *lock*) (loop (- n 1))) (else - (write "producer thread done"))))) + (display "producer thread done") + (newline))))) (define (consumer) (let loop () - ;(write (list (null? *queue*) *queue*)) + ;(display (list (null? *queue*) *queue*)) + ;(newline) (define sleep? #f) (mutex-lock! *lock*) (cond ((not (null? *queue*)) - (write (car *queue*)) + (display (car *queue*)) + (newline) (set! *queue* (cdr *queue*))) (else - (write "consumer sleeping") + (display "consumer sleeping") + (newline) (set! sleep? #t))) (mutex-unlock! *lock*) (if sleep? (thread-sleep! 1000)) diff --git a/examples/threading/thread-join.scm b/examples/threading/thread-join.scm index eaef96c1..2aaebbcc 100644 --- a/examples/threading/thread-join.scm +++ b/examples/threading/thread-join.scm @@ -11,13 +11,16 @@ (thread-start! (make-thread (lambda () - (write "started thread") + (display "started thread") + (newline) (thread-sleep! 3000) - (write "thread done") + (display "thread done") + (newline) (condition-variable-broadcast! cv)))) ;; Main thread - wait for thread to broadcast it is done (mutex-lock! m) (mutex-unlock! m cv) ;; Wait on cv -(write "main thread done") +(display "main thread done") +(newline) (thread-sleep! 500)