[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-janitors] #1127: dynamic wind in its own thread
From: |
Chicken Trac |
Subject: |
Re: [Chicken-janitors] #1127: dynamic wind in its own thread |
Date: |
Thu, 22 May 2014 15:15:16 -0000 |
#1127: dynamic wind in its own thread
-------------------------+--------------------------------------------------
Reporter: kristianlm | Owner:
Type: defect | Status: new
Priority: major | Milestone: someday
Component: unknown | Version: 4.9.x
Resolution: | Keywords:
-------------------------+--------------------------------------------------
Comment(by kristianlm):
Meanwhile, here's a workaround:
{{{
(use srfi-18 test)
;; define address@hidden once
(define original#thread-start!
(handle-exceptions e thread-start!
original#thread-start!))
(define (##dbg#thread-thunk thread)
(##sys#slot thread 1))
(define (thread-start! thread)
;; original thunk
(define original-thunk
(if (thread? thread)
(##dbg#thread-thunk thread)
thread))
;; simply wrap original thunk inside a handle-exceptions with
;; re-raises any errors seem to do the trick
(define (thunk)
(handle-exceptions e (raise e)
(original-thunk)))
(original#thread-start!
(if (thread? thread)
(make-thread thunk (thread-name thread))
(make-thread thunk))))
(test-group
"dynamic-wind.workaround"
(define ran? #f)
(define (trick)
(dynamic-wind (lambda () (void))
(lambda () (error 'x))
(lambda () (set! ran? #t))))
;; throw away warnings
(parameterize ((current-error-port (open-output-string)))
(test-error
(thread-join!
(thread-start!
(lambda () (trick))))))
(test #t ran?))
}}}
This test-group passes, but fails if you don't redefine {{{thread-
start!}}}.
--
Ticket URL: <http://bugs.call-cc.org/ticket/1127#comment:1>
CHICKEN Scheme <http://www.call-with-current-continuation.org/>
CHICKEN Scheme is a compiler for the Scheme programming language.