From: Marius Vollmer <mvo@zagadka.ping.de>
Cc: bug-guile@gnu.org
Subject: Re: no output from ice-9 `format' after `make-thread'
Date: 03 Nov 2002 01:00:51 +0100 [thread overview]
Message-ID: <87znsrcyj0.fsf@zagadka.ping.de> (raw)
In-Reply-To: <87d6pn1stf.fsf@blarg.net>
Eric Hanchrow <offby1@blarg.net> writes:
> Invoke the snippet with `guile -s snippet.scm'. Note the total lack
> of output.
The process exits before it can produce any output. "guile -s" exits
as soon as the main thread exits. (The builtin simple-format is
probably fast enough to produce output anyway.)
Try this:
(use-modules (ice-9 threads))
(use-modules (ice-9 format))
(define safe-format
(let ((m (make-mutex)))
(lambda args
(with-mutex m
(apply format args)))))
(let ((ts (map (lambda (sym)
(make-thread
(lambda ()
(sleep (random 4))
(safe-format #t "Hey you: ~A~%" sym))))
(list 'bob 'sam 'huey 'luey 'duey))))
(for-each join-thread ts))
It uses join-thread to wait for the threads to finish.
Note also that (ice-9 format) is not thread safe... (which I'm going
to fix soonish (when nothing preempts me)).
--
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3 331E FAF8 226A D5D4 E405
_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://mail.gnu.org/mailman/listinfo/bug-guile
next prev parent reply other threads:[~2002-11-03 0:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-02 22:59 no output from ice-9 `format' after `make-thread' Eric Hanchrow
2002-11-03 0:00 ` Marius Vollmer [this message]
2002-11-04 18:52 ` Neil Jerram
2002-11-17 15:00 ` Marius Vollmer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87znsrcyj0.fsf@zagadka.ping.de \
--to=mvo@zagadka.ping.de \
--cc=bug-guile@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).