1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 20:00:19 +02:00

futures: Add a record printer.

* module/ice-9/futures.scm: Add a record printer for <future>.
This commit is contained in:
Ludovic Courtès 2012-11-16 23:51:59 +01:00
parent f2fb5e5328
commit ab975cf592

View file

@ -19,6 +19,7 @@
(define-module (ice-9 futures) (define-module (ice-9 futures)
#:use-module (srfi srfi-1) #:use-module (srfi srfi-1)
#:use-module (srfi srfi-9) #:use-module (srfi srfi-9)
#:use-module (srfi srfi-9 gnu)
#:use-module (ice-9 threads) #:use-module (ice-9 threads)
#:use-module (ice-9 q) #:use-module (ice-9 q)
#:export (future make-future future? touch)) #:export (future make-future future? touch))
@ -52,6 +53,14 @@
(mutex future-mutex) (mutex future-mutex)
(completion future-completion)) ; completion cond. var. (completion future-completion)) ; completion cond. var.
(set-record-type-printer!
<future>
(lambda (future port)
(simple-format port "#<future ~a ~a ~s>"
(number->string (object-address future) 16)
(future-state future)
(future-thunk future))))
(define (make-future thunk) (define (make-future thunk)
"Return a new future for THUNK. Execution may start at any point "Return a new future for THUNK. Execution may start at any point
concurrently, or it can start at the time when the returned future is concurrently, or it can start at the time when the returned future is