Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions gui-lib/framework/private/text-port.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,10 @@
(channel-put box-read-chan (cons eof (position->line-col-pos unread-start-point))))
(define/public-final (clear-input-port) (channel-put clear-input-chan (void)))
(define/public-final (clear-box-input-port) (channel-put box-clear-input-chan (void)))
(define/public-final (clear-output-ports)

(define output-ports-clear-count 0)
(define/public-final (clear-output-ports)
(set! output-ports-clear-count (add1 output-ports-clear-count))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rfindler this is the only place that writes to output-ports-clear-count, so provided that there is only one thread that calls (clear-output-ports), I think there won't be a race condition?

(channel-put clear-output-chan (void))
(init-output-ports))

Expand Down Expand Up @@ -525,9 +528,11 @@
;; thread: any thread, except the eventspace main thread
(define/private (queue-insertion txts signal #:async? [async? #f])
(parameterize ([current-eventspace eventspace])
(define current-clear-count output-ports-clear-count)
(queue-callback
(λ ()
(do-insertion txts #f)
(when (= current-clear-count output-ports-clear-count)
(do-insertion txts #f))
(if async? (thread (λ () (sync signal))) (sync signal)))
#f)))

Expand Down