Re: maybe-commit-and-make-ready-and-block

Taylor R Campbell <[email protected]>
Newsgroups gmane.lisp.scheme.scheme48
Message-ID <[email protected]>
More generally, it would be nice if the transaction abstraction
supported hooks for success and failure: lists of procedures to be run
either on success or on failure of committing the transaction's
proposal.  That would make MAYBE-COMMIT-AND-MAKE-READY-AND-BLOCK
mostly unnecessary, as well as MAYBE-COMMIT-AND-MAKE-READY and
MAYBE-COMMIT-AND-CHANNEL-{READ,WRITE}, although the hooks would have
to be arranged very carefully concerning interrupts, and I don't have
a good solution off hand for that.  (Blocking is still a special case
worth naming, though.)

This way, it would be possible for the thread system to provide a
PROVISIONAL-MAKE-READY procedure, enabling composition of transactions
that try to make threads ready.  For example, given such a procedure,
one could define PROVISIONAL-PLACEHOLDER-SET!, and thereby enable
transactions in independent parts of a program that set different
placeholders to be composed into a single atomic transaction.

(define (provisional-placeholder-set! placeholder value)
  (call-ensuring-atomicity!
   (lambda ()
     (let ((queue (placeholder-queue placeholder)))
       (cond (queue
              (set-placeholder-value! placeholder value)
              (set-placeholder-queue! placeholder #f)
              (provisional-make-ready queue))
             (else
              (error ...)))))))

(define (placeholder-set! placeholder value)
  (atomically! (provisional-placeholder-set! placeholder value)))
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.