[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debbugs-tracker] bug#21887: closed ('monitor' form broken)

From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#21887: closed ('monitor' form broken)
Date: Mon, 27 Jun 2016 07:34:02 +0000

Your message dated Mon, 27 Jun 2016 09:33:36 +0200
with message-id <address@hidden>
and subject line Re: bug#21887: 'monitor' form broken
has caused the debbugs.gnu.org bug report #21887,
regarding 'monitor' form broken
to be marked as done.

(If you believe you have received this mail in error, please contact

21887: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=21887
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: 'monitor' form broken Date: Thu, 12 Nov 2015 16:29:30 +0100 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)
It seems that the 'monitor' form is currently a no-op.  The form

    (par-for-each (lambda (x)

should be functionally equivalent to

    (let ((mutex (make-mutex)))
      (par-for-each (lambda (x)
                      (with-mutex mutex

but currently becomes

    (par-for-each (lambda (x)
                    (let ((mutex (make-mutex)))
                      (with-mutex mutex

which is ineffective.

I don't know what's the best way to fix this.  The simplest thing that
comes to my mind is something along the lines of:

    (define-syntax monitor
      (lambda (stx)
        (syntax-case stx ()
          ((_ body body* ...)
           (let ((uuid (generate-uuid)))
             #`(with-mutex (mutex-with-uuid #,uuid)
                 body body* ...))))))

where mutex-with-uuid looks it up from a hash table at run-time and
instantiates it when it doesn't exist, this operation also being
synchronized across threads, like:

    (define mutex-table (make-hash-table))

    (define mutex-table-mutex (make-mutex))

    (define (mutex-with-uuid uuid)
      (with-mutex mutex-table-mutex
        (or (hash-ref mutex-table uuid)
            (let ((mutex (make-mutex)))
              (hash-set! mutex-table uuid mutex)

If that looks OK, I can try to make a proper patch from it.  I'm not
sure what I'd use in place of `generate-uuid' though.  Would `gensym' be
good enough?

Shameless advertisement: with SRFI-126, the (or (hash-ref ...) ...) bit
would have been just:

    (hashtable-intern! mutex-table uuid make-mutex)

It's borrowed from MIT/GNU Scheme.  Seems pretty useful.


--- End Message ---
--- Begin Message --- Subject: Re: bug#21887: 'monitor' form broken Date: Mon, 27 Jun 2016 09:33:36 +0200 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]