Skip to content

Conversation

@sorawee
Copy link
Contributor

@sorawee sorawee commented Sep 23, 2022

When we press the kill button, make it so that queued up "do-insertion"s are not processed.

This code is originally authored by @rfindler

Fixes racket/racket#1677 and racket/drracket#444

When we press the kill button, make it so that queued up
"do-insertion"s are not processed.

This code is originally authored by @rfindler

Fixes racket/racket#1677 and #444

(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?

@capfredf
Copy link
Member

I've fixed the CI issue in #282

@rfindler
Copy link
Member

There's a race because the set! happens in one thread and the lookup ((define current-clear-count output-ports-clear-count)) happens in a different thread. I think that because racket guarantees sequential consistency for thread (it doesn't for futures or places) that this race condition is benign and probably this is okay, overall.

That said, I feel like it would be better if there were some way to use the existing syncronization that's happening in this code to be able to cancel the pending work.

@sorawee
Copy link
Contributor Author

sorawee commented Oct 2, 2022

Closing in favor of b51090c

@sorawee sorawee closed this Oct 2, 2022
@sorawee sorawee deleted the fix-kill-output branch October 2, 2022 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DrRacket stop button cannot stop printing quickly (when there are no newlines)

3 participants