fix more try-atomic problems

This commit is contained in:
Matthew Flatt 2010-12-21 18:45:36 -07:00
parent 391e7f486f
commit 78b2e47541
3 changed files with 16 additions and 7 deletions

View File

@ -15,10 +15,13 @@
(define scheme_restore_on_atomic_timeout (define scheme_restore_on_atomic_timeout
(get-ffi-obj 'scheme_set_on_atomic_timeout #f (_fun _pointer -> _pointer))) (get-ffi-obj 'scheme_set_on_atomic_timeout #f (_fun _pointer -> _pointer)))
(define freezer-box (make-parameter #f)) (define freezer-box-key (gensym))
(define freeze-tag (make-continuation-prompt-tag)) (define freeze-tag (make-continuation-prompt-tag))
(define force-timeout (make-parameter #f)) (define force-timeout (make-parameter #f))
(define (freezer-box)
(continuation-mark-set-first #f freezer-box-key))
;; Runs `thunk' atomically, but cooperates with ;; Runs `thunk' atomically, but cooperates with
;; `try-atomic' to continue a frozen ;; `try-atomic' to continue a frozen
;; computation in non-atomic mode. ;; computation in non-atomic mode.
@ -36,13 +39,14 @@
;; Start with an empty list of things to finish: ;; Start with an empty list of things to finish:
null))]) null))])
(begin0 (begin0
(parameterize ([freezer-box b]) (with-continuation-mark freezer-box-key b
;; In atomic mode (but not using call-as-atomic, because we ;; In atomic mode (but not using call-as-atomic, because we
;; don't want to change the exception handler, etc.) ;; don't want to change the exception handler, etc.)
(start-atomic) (begin
(begin0 (start-atomic)
(thunk) (begin0
(end-atomic))) (thunk)
(end-atomic))))
;; Retries out of atomic mode: ;; Retries out of atomic mode:
(let ([l (unbox b)]) (let ([l (unbox b)])
(for ([k (in-list (reverse l))]) (for ([k (in-list (reverse l))])

View File

@ -210,7 +210,8 @@
[(= msg WM_CLOSE) [(= msg WM_CLOSE)
(queue-window-event this (lambda () (queue-window-event this (lambda ()
(when (on-close) (when (on-close)
(direct-show #f)))) (atomically
(direct-show #f)))))
0] 0]
[(and (= msg WM_SIZE) [(and (= msg WM_SIZE)
(not (= wParam SIZE_MINIMIZED))) (not (= wParam SIZE_MINIMIZED)))

View File

@ -4634,7 +4634,11 @@ int scheme_wait_until_suspend_ok(void)
while (do_atomic && scheme_on_atomic_timeout) { while (do_atomic && scheme_on_atomic_timeout) {
did = 1; did = 1;
if (atomic_timeout_auto_suspend)
atomic_timeout_auto_suspend++;
call_on_atomic_timeout(1); call_on_atomic_timeout(1);
if (atomic_timeout_auto_suspend > 1)
--atomic_timeout_auto_suspend;
} }
return did; return did;